Skip to content

Fix infrahubctl proposed change table generation#805

Merged
gmazoyer merged 3 commits intoinfrahub-developfrom
gma-20260203-ctl-fix-pc-report
Feb 6, 2026
Merged

Fix infrahubctl proposed change table generation#805
gmazoyer merged 3 commits intoinfrahub-developfrom
gma-20260203-ctl-fix-pc-report

Conversation

@gmazoyer
Copy link
Contributor

@gmazoyer gmazoyer commented Feb 6, 2026

This was broken because the API server will now expose the created_by and created_at values inside the node metadata.

Also add get_node_metadata to CoreNodeBase protocol.

Summary by CodeRabbit

  • New Features

    • Added a public API to retrieve node-specific metadata.
  • Improvements

    • Branch reporting now computes and displays creator and timestamp info from node metadata.
    • Proposed-change retrieval updated to use metadata-based inclusion for richer results.
  • Tests

    • Updated unit tests to reflect the revised node metadata structure.
  • Documentation

    • Added changelog entry describing the metadata-based branch report change.

This was broken because the API server will now expose the `created_by`
and `created_at` values inside the node metadata.

Also add `get_node_metadata` to `CoreNodeBase` protocol.
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Walkthrough

A new optional protocol method CoreNodeBase.get_node_metadata() was added. Branch report logic was refactored to compute node metadata at the start of each proposed change, derive created_by and created_at from that metadata, and use include_metadata=True when fetching proposed changes. Tests were updated to use a unified node_metadata structure containing creation and update timestamps and creator details. A changelog entry records the report behavior change.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adapting proposed change table generation to use node metadata instead of direct attribute access.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 6, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 68a1479
Status: ✅  Deploy successful!
Preview URL: https://cbe81a7b.infrahub-sdk-python.pages.dev
Branch Preview URL: https://gma-20260203-ctl-fix-pc-repo.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/protocols_base.py 0.00% 0 Missing and 1 partial ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #805      +/-   ##
====================================================
+ Coverage             80.32%   80.46%   +0.13%     
====================================================
  Files                   115      117       +2     
  Lines                  9867    10226     +359     
  Branches               1504     1547      +43     
====================================================
+ Hits                   7926     8228     +302     
- Misses                 1420     1462      +42     
- Partials                521      536      +15     
Flag Coverage Δ
integration-tests 40.19% <0.00%> (-1.25%) ⬇️
python-3.10 51.83% <83.33%> (+0.46%) ⬆️
python-3.11 51.83% <83.33%> (+0.46%) ⬆️
python-3.12 51.85% <83.33%> (+0.48%) ⬆️
python-3.13 51.83% <83.33%> (+0.46%) ⬆️
python-3.14 53.53% <83.33%> (+0.51%) ⬆️
python-filler-3.12 24.00% <0.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/branch.py 81.48% <100.00%> (+0.34%) ⬆️
infrahub_sdk/protocols_base.py 73.43% <0.00%> (-0.58%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmazoyer gmazoyer marked this pull request as ready for review February 6, 2026 15:20
@gmazoyer gmazoyer requested a review from a team as a code owner February 6, 2026 15:20
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@infrahub_sdk/ctl/branch.py`:
- Around line 113-116: The current assignment of created_by from metadata (via
pc.get_node_metadata()) can yield the literal string "None" when
metadata.created_by.display_label is None; update the guard around created_by so
it checks that metadata, metadata.created_by, and
metadata.created_by.display_label are truthy and fall back to "-" otherwise
(adjust the code in the block that calls get_node_metadata(), where created_by
is computed, and keep format_timestamp usage for created_at as-is).

Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

This will of course only work for installations after Infrahub 1.7. It might be that this being targeted for infrahub-develop would mean that it only gets included in an SDK version that will require Infrahub 1.8. Not related to this PR, just feels like it would be nice to have this resolved. For this version we should probably clearly state in the release notes of the SDK to highlight what release is required. Then after that we can hopefully avoid breaking changes between version.

@gmazoyer gmazoyer merged commit 2e6c3f8 into infrahub-develop Feb 6, 2026
21 checks passed
@gmazoyer gmazoyer deleted the gma-20260203-ctl-fix-pc-report branch February 6, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants