Skip to content

bug: Provided name cannot be used as python identifier.Β #712

@BaptisteGi

Description

@BaptisteGi

Component

No response

Infrahub SDK version

1.17.0

Current Behavior

When running the command infrahubctl graphql generate-return-types query1.gql I got the following exception:

Error: Provided name  cannot be used as python identifier.
    raise InvalidConfiguration(
ariadne_codegen.exceptions.InvalidConfiguration: Provided name  cannot be used as python identifier.

Expected Behavior

I expect the command to work

Steps to Reproduce

  • Setup project
mkdir some-project
cd some-project
uv init
uv add 'infrahub-sdk[all]'
export INFRAHUB_API_TOKEN=06438eb2-8019-4776-878c-0941b1f1d1ec
  • Create a query1.gql with the following content:
query Test {
  BuiltinTag {
    edges {
      node {
        name {
          value
        }
      }
    }
  }
}
  • Run command infrahubctl graphql export-schema
  • Then infrahubctl graphql generate-return-types query1.gql

=> This fails with Error: Provided name cannot be used as python identifier.

Additional Information

The problem is that directory.name is empty when the GraphQL file is in the current directory.

target_package_name=directory.name,

So either we force people to put their queries in a folder, or we adjust code to account for local folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions