You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Provided name cannot be used as python identifier. #712
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.
Fix the generate-return-types command to work when GraphQL query files are located in the current directory by providing a valid default package name instead of an empty string.
Observations
The infrahub-sdk uses Typer for CLI commands organized into modular apps under infrahub_sdk/ctl/. The GraphQL module (infrahub_sdk/ctl/graphql.py) integrates with ariadne-codegen v0.15.3 to generate Pydantic models from GraphQL queries. The command processes .gql files grouped by directory and generates separate client packages for each directory using ariadne-codegen's ClientSettings with a target_package_name parameter.
AssumptionsAssumption 1: What package name should be used for queries in the current directory?
Options Considered:
Use "graphql_client" (ariadne-codegen's default package name)
Use "queries" (a custom descriptive name)
Use the actual current directory name from filesystem (requires sanitization)
Chosen Option: Use "graphql_client" as the default
Rationale: This aligns with ariadne-codegen's own default behavior, provides a predictable and valid Python package name, and requires minimal code change. Developers familiar with ariadne-codegen will recognize this conventional name, and it avoids complexity around sanitizing arbitrary directory names.
💡 User Tips
Regenerate the plan with different choices with @coderabbitai <feedback>.
Implementation Steps
Fix Empty Package Name Bug
This phase addresses the core issue by ensuring a valid package name is always provided to ariadne-codegen.
Add Default Package Name Fallback
Modify the package name generation to use a fallback when the directory name is empty.
Update infrahub_sdk/ctl/graphql.py at line 160 to change target_package_name=directory.name to target_package_name=directory.name or "graphql_client"
This ensures that when .gql files are in the current directory (where Path.cwd().name or Path('.').name returns empty string), a valid default package name is used
The fallback value "graphql_client" matches ariadne-codegen's default convention and is guaranteed to be a valid Python identifier
🤖 Prompt for AI agents
Fix the empty package name bug in the generate-return-types command.
In `infrahub_sdk/ctl/graphql.py`:
- Modify the `target_package_name` assignment to use a fallback value
- Change from `target_package_name=directory.name` to
`target_package_name=directory.name or "graphql_client"`
- This ensures a valid package name when `.gql` files are in the current
directory
🚀 Next Steps
🤖 All AI agent prompts combined
Fix the empty package name bug in the generate-return-types command.
In `infrahub_sdk/ctl/graphql.py`:
- Modify the `target_package_name` assignment to use a fallback value
- Change from `target_package_name=directory.name` to
`target_package_name=directory.name or "graphql_client"`
- This ensures a valid package name when `.gql` files are in the current
directory
💡 Iterate on the plan with:
@coderabbitai <feedback>
Example Feedback
- @coderabbitai You can skip phase 3. Add a simple unit test case for phase 2.
- @coderabbitai For assumption 1 go ahead with option 3 and replan.
💬 Have feedback or questions? Drop into our discord!
Activity
coderabbitai commentedon Dec 29, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
✅ Successfully generated implementation plan.
💡 Use
@coderabbitai <feedback>to replanExamples
🔗 Similar Issues
Related Issues
AttributeErrorif not a valid attribute. #445query_gql_querydoesn't take into account client config #236👤 Suggested Assignees
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
coderabbitai commentedon Dec 29, 2025
Coding Plan
Approach
Fix the
generate-return-typescommand to work when GraphQL query files are located in the current directory by providing a valid default package name instead of an empty string.Observations
The infrahub-sdk uses Typer for CLI commands organized into modular apps under
infrahub_sdk/ctl/. The GraphQL module (infrahub_sdk/ctl/graphql.py) integrates with ariadne-codegen v0.15.3 to generate Pydantic models from GraphQL queries. The command processes.gqlfiles grouped by directory and generates separate client packages for each directory using ariadne-codegen'sClientSettingswith atarget_package_nameparameter.Assumptions
Assumption 1: What package name should be used for queries in the current directory?
Options Considered:
Chosen Option: Use "graphql_client" as the default
Rationale: This aligns with ariadne-codegen's own default behavior, provides a predictable and valid Python package name, and requires minimal code change. Developers familiar with ariadne-codegen will recognize this conventional name, and it avoids complexity around sanitizing arbitrary directory names.
💡 User Tips
Regenerate the plan with different choices with
@coderabbitai <feedback>.Implementation Steps
Fix Empty Package Name Bug
This phase addresses the core issue by ensuring a valid package name is always provided to ariadne-codegen.
Add Default Package Name Fallback
Modify the package name generation to use a fallback when the directory name is empty.
infrahub_sdk/ctl/graphql.pyat line 160 to changetarget_package_name=directory.nametotarget_package_name=directory.name or "graphql_client".gqlfiles are in the current directory (wherePath.cwd().nameorPath('.').namereturns empty string), a valid default package name is used🤖 Prompt for AI agents
🚀 Next Steps
🤖 All AI agent prompts combined
💡 Iterate on the plan with:
@coderabbitai <feedback>💬 Have feedback or questions? Drop into our discord!
Fix issue #712
Fix issue #713 and #712 (#714)