Component
Git Integration
Infrahub Version
1.8.2
Current Behavior
When a repository is configured in read-write mode with a default branch other than main (e.g., master, develop), Infrahub fails to generate artifacts from that repository. The repository's operational state transitions to an error.
Expected Behavior
Artifact generation should work regardless of the repository's default branch name. The system should respect the default_branch attribute configured on the repository object.
Steps to Reproduce
- Create an external Git repository with a default branch named something other than
main (e.g., master)
- Add it to Infrahub as a read-write repository, setting
default_branch to match
- Configure an artifact definition that pulls data from this repository
- Trigger artifact generation
- Observe that the repository operational state becomes an error
Analysis
Several locations in the codebase have hardcoded assumptions about "main" as the branch name:
backend/infrahub/git/base.py:204 — directory_default property hardcodes "main" as the directory name for the primary branch worktree
backend/infrahub/git/base.py:868-870 — worktree identifier mapping uses "main" as a fallback identifier when the repository's default branch differs from the system default
backend/infrahub/git/repository.py:194 — rebase() defaults source_branch to "main"
backend/infrahub/core/schema/definitions/core/repository.py:44 — schema default_value="main" (this one is expected as a default, but the runtime code should honor the configured value)
The default_branch property in base.py:187-189 correctly falls back from default_branch_name to registry.default_branch, but downstream code that hardcodes "main" as a directory or identifier bypasses this logic.
Component
Git Integration
Infrahub Version
1.8.2
Current Behavior
When a repository is configured in read-write mode with a default branch other than
main(e.g.,master,develop), Infrahub fails to generate artifacts from that repository. The repository's operational state transitions to an error.Expected Behavior
Artifact generation should work regardless of the repository's default branch name. The system should respect the
default_branchattribute configured on the repository object.Steps to Reproduce
main(e.g.,master)default_branchto matchAnalysis
Several locations in the codebase have hardcoded assumptions about "main" as the branch name:
backend/infrahub/git/base.py:204—directory_defaultproperty hardcodes"main"as the directory name for the primary branch worktreebackend/infrahub/git/base.py:868-870— worktree identifier mapping uses"main"as a fallback identifier when the repository's default branch differs from the system defaultbackend/infrahub/git/repository.py:194—rebase()defaultssource_branchto"main"backend/infrahub/core/schema/definitions/core/repository.py:44— schemadefault_value="main"(this one is expected as a default, but the runtime code should honor the configured value)The
default_branchproperty inbase.py:187-189correctly falls back fromdefault_branch_nametoregistry.default_branch, but downstream code that hardcodes"main"as a directory or identifier bypasses this logic.