Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting when a union is discriminated by a Literal type field #48

Open
NiklasRosenstein opened this issue Jun 6, 2023 · 0 comments

Comments

@NiklasRosenstein
Copy link
Owner

Example error message:

databind.core.converter.ConversionError: unable to deserialize any union member

Trace:
    $: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace)
    .workflow: TypeHint(typing.Union[helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.ApiDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.CliDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.VcsDrivenWorkflow])

The following errors have been reported by converters:

  databind.json.converters.SchemaConverter(): encountered extra keys: {'providersFrom'}

    Trace:
        $: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace)
        .workflow: TypeHint(typing.Union[helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.ApiDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.CliDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.VcsDrivenWorkflow])
        ^: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.ApiDrivenWorkflow)

  databind.json.converters.LiteralConverter(): literal value mismatch: got 'ApiDriven', expected 'CliDriven'

    Trace:
        $: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace)
        .workflow: TypeHint(typing.Union[helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.ApiDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.CliDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.VcsDrivenWorkflow])
        ^: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.CliDrivenWorkflow)
        .type: TypeHint(typing.Literal['CliDriven'])

  databind.json.converters.SchemaConverter(): missing required field: 'vcsProvider'

    Trace:
        $: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace)
        .workflow: TypeHint(typing.Union[helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.ApiDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.CliDrivenWorkflow, helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.VcsDrivenWorkflow])
        ^: TypeHint(helsing.scm.resources.v1alpha1.TerraformWorkspace.TerraformWorkspace.VcsDrivenWorkflow)

The value of the discriminator is set to VcsDriven, then only the matching members of the union should be tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant