Skip to content

bug(cli): switching to an invalid context breaks ado #618

@AlessandroPomponio

Description

@AlessandroPomponio

Issue

Running

ado context an-invalid-context

Works no matter what if the context exists, because no checks are performed whether the context is actually valid or not.

Upon running any other kind of command, however, if the context isn't valid, Pydantic will raise ValidationErrors which will prevent the user from running anything else, even switching context.

Example

(ado-core) alessandropomponio@MacBook-Pro-di-Alessandro ~/D/G/p/ado ((8684a72e))> ado context ap-testing
  warnings.warn(
Success! Now using context ap-testing
(ado-core) alessandropomponio@MacBook-Pro-di-Alessandro ~/D/G/p/ado ((8684a72e))> ado upgrade stores
  warnings.warn(
ERROR:  The provided project context was not valid:
        2 validation errors for ProjectContext
metadataStore.mysql.active
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
sslVerify
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
(ado-core) alessandropomponio@MacBook-Pro-di-Alessandro ~/D/G/p/ado ((8684a72e)) [1]> ado context ft-prod
  warnings.warn(
ERROR:  The provided project context was not valid:
        2 validation errors for ProjectContext
metadataStore.mysql.active
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
sslVerify
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
(ado-core) alessandropomponio@MacBook-Pro-di-Alessandro ~/D/G/p/ado ((8684a72e)) [1]> ado context local
  warnings.warn(
ERROR:  The provided project context was not valid:
        2 validation errors for ProjectContext
metadataStore.mysql.active
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
sslVerify
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
(ado-core) alessandropomponio@MacBook-Pro-di-Alessandro ~/D/G/p/ado ((8684a72e)) [1]> ado template context --local-context
  warnings.warn(
ERROR:  The provided project context was not valid:
        2 validation errors for ProjectContext
metadataStore.mysql.active
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
sslVerify
  Extra inputs are not permitted 
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions