Skip to content

bug: client.branch.validate() has been broken since Infrahub 1.1.0 — it queries a messages field removed from BranchValidate #1263

Description

@lancamat1

Component

Python SDK, infrahubctl

Infrahub SDK version

1.23.0 (latest release), and the current default branch

Current Behavior

client.branch.validate() cannot succeed against any supported Infrahub server. Every call raises:

infrahub_sdk.exceptions.GraphQLError: An error occurred while executing the GraphQL Query
[{'message': "Cannot query field 'messages' on type 'BranchValidate'",
  'locations': [{'line': 9, 'column': 9}],
  'extensions': {'code': 'UNDEFINED_ERROR', 'http_status': 500, 'data': {}}}]

The SDK includes "messages": None in the mutation's query_data, in both the async InfrahubBranchManager.validate() (infrahub_sdk/branch.py:138) and the sync InfrahubBranchManagerSync.validate() (infrahub_sdk/branch.py:293). Line numbers are the same on v1.23.0 and on the default branch.

The server stopped exposing that field nearly two years ago. messages = List(String) was removed from BranchValidate by commit 1745bf5090a92a04ba51f80ce4c51c67d571ca09 (2024-11-07, #4868, "Convert BranchValidate mutation to a prefect task and add support for async execution"), which also removed the validation_messages accumulation that fed it. That commit is an ancestor of infrahub-v1.1.0 (behind_by: 0), so the field has been absent since Infrahub 1.1.0, released 2024-12-30. At infrahub-v1.11.0, BranchValidate declares exactly ok, object and task.

infrahubctl branch validate fails the same way — it is the only caller of this method in the repository (infrahub_sdk/ctl/branch.py).

Expected Behavior

client.branch.validate() and infrahubctl branch validate return the validation result against a current Infrahub server, requesting only fields the mutation exposes.

Steps to Reproduce

  1. Run any Infrahub server at 1.1.0 or later (observed on 1.11.0 via infrahub-testcontainers 1.11.0).
  2. With infrahub-sdk 1.23.0:
    await client.branch.validate(branch_name="some-branch")
  3. Observe the GraphQLError above. The rendered mutation places messages at line 9, column 9, matching the reported error location.
  4. The sync client and infrahubctl branch validate <branch> fail identically.

Additional Information

The SDK ships the disproof of its own query. The committed server schema fixture tests/fixtures/unit/test_graphql_plugin/schema.graphql (19,406 lines) contains:

type BranchValidate {
  ok: Boolean
  object: Branch
  task: TaskInfo
}

The word messages does not appear anywhere in that file.

Why this survived ~20 months: there is no test coverage. tests/unit/sdk/test_branch.py holds four tests — test_method_sanity, test_validate_method_signature, test_get_branches, test_branch_merge_enforces_minimum_timeout. None calls branch.validate(). The integration suites (tests/integration/test_infrahub_client.py, test_infrahub_client_sync.py) exercise branch.create / all / get / delete only, and there is no test for the infrahubctl branch validate command. Worth noting that test_validate_method_signature is a check of async/sync signature parity, not a test of branch.validate — so a grep for "validate" in the branch tests reads as covered when it is not.

Precedent for this class of defect. #1229 (merged 2026-08-11) removed client.branch.diff_data() because it called a server surface deleted in opsmill/infrahub#4865 — a PR adjacent to the #4868 that removed messages. Both look like collateral of the same late-2024 refactor, and the reasoning recorded in #1229 applies here too.

One observation relevant to scoping, not a proposed fix: both validate() variants end in return response["BranchValidate"]["ok"], so neither messages nor object is ever read from the response.

Noticed adjacent to this and deliberately left out of scope: validate() is annotated -> BranchData but returns a bool, and rebase() carries the same annotation mismatch. Happy to file that separately if useful.

Found while writing branch and proposed-change integration tests, where validate() was the natural pre-merge check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowThis issue should be completed in a couple of hourstype/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