Skip to content

bug: get_diff_summary() reports operationName GetDiffTree instead of its own operation #1313

Description

@BeArchiTek

Component

Python SDK

Infrahub SDK version

1.23.1 (verified on develop @ 9b39ab4)

Current Behavior

get_diff_summary() sends its request under the wrong GraphQL operation name. It builds the summary query but reports the operation as GetDiffTree.

infrahub_sdk/client.py, sync at :3386 (async at :1794):

def get_diff_summary(self, branch, name=None, from_time=None, to_time=None, ...):
    query = get_diff_summary_query()
    ...
    response = self.execute_graphql(
        query=query,
        branch_name=branch,
        timeout=timeout,
        tracker=tracker,
        variables=input_data,
        operation_name="GetDiffTree",   # <- hardcoded, and belongs to the other method
        priority=priority,
    )

get_diff_tree() gets this right — it passes operation_name=query.name (:3462 sync, :1870 async). Only the summary path hardcodes a literal, and the literal it hardcodes is the other method's operation.

Effect: get_diff_summary and get_diff_tree are indistinguishable in server-side query logs, traces and any observability tooling keyed on operationName. Two different queries with different cost profiles are attributed to one name.

This works against two changes made deliberately in 1.22.0 — adding query_name "to be used as meaningful GraphQL operation name for observability" (#923), and sending "the GraphQL operation name as operationName in the request payload so tracing and observability tools can identify each query".

Expected Behavior

get_diff_summary() reports its own operation name, most simply by using the query's own name the way get_diff_tree() already does:

operation_name=query.name,

Both async and sync clients need the change. If get_diff_summary_query() does not expose a distinct .name, giving it one (e.g. GetDiffSummary) is part of the fix.

Steps to Reproduce

  1. Enable GraphQL query logging on the Infrahub server (or point the client at any HTTP proxy that records request bodies).
  2. Call client.get_diff_summary(branch="some-branch").
  3. Inspect the request payload: operationName is GetDiffTree, not a summary-specific name.
  4. Call client.get_diff_tree(branch="some-branch") — the same operationName is reported for a different query.

Additional Information

Small fix, filed for completeness after an audit of the diff methods.

While looking at this: #529 ("task: Implement functions to perform the DiffUpdate mutation") appears to be already done — create_diff() performs DiffUpdate, and the 1.15.0 changelog credits #529. It may be closeable.

Found while auditing which SDK capabilities the opsmill.infrahub Ansible collection does not yet expose. Related collection issue: opsmill/infrahub-ansible#396.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowThis issue should be completed in a couple of hoursstate/need-triageThis issue needs to be triagedtype/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