Skip to content

Conversation

@minitriga
Copy link
Contributor

@minitriga minitriga commented Jan 22, 2026

…n; enhance handling of RelatedNode inputsAdd allow_upsert option to LineDelimitedJSONImporter and load function; enhance handling of RelatedNode inputs

Summary by CodeRabbit

  • New Features

    • Added an allow_upsert option to the import command to control upsert behavior during imports.
  • Improvements

    • More robust handling and serialization of related-node-like objects to ensure IDs are used where appropriate.
    • Reduced duplicate relationship entries and simplified relationship detection for exports.
    • Improved consistency when importing existing records.
  • Tests

    • Added and updated tests covering upsert imports and related-node data handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

This pull request wires a new boolean allow_upsert option from the CLI load command into the importer and LineDelimitedJSONImporter, exposing importer-level control over upsert behavior. It adjusts GraphQL rendering to serialize the id of RelatedNode-like objects instead of the object. RelatedNodeBase.init now accepts another RelatedNodeBase as input by converting it to a dict with id, hfid, and __typename. The JSON exporter renames and refactors a helper to identify_many_relationships. Tests were added/updated to cover these changes.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 'Add allow_upsert option to LineDelimitedJSONImporter' accurately describes the main change: introducing a new allow_upsert parameter throughout the import pipeline (CLI, importer initialization, and JSON importer). While the PR also includes enhancements to RelatedNode handling and GraphQL rendering, the primary and most prominent change is the allow_upsert option addition.

✏️ 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 Jan 22, 2026

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: ce6441e
Status: ✅  Deploy successful!
Preview URL: https://ca8ca874.infrahub-sdk-python.pages.dev
Branch Preview URL: https://atg-20260122-ctl-load.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

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

Files with missing lines Patch % Lines
infrahub_sdk/graphql/renderers.py 75.00% 0 Missing and 1 partial ⚠️
@@            Coverage Diff             @@
##           stable     #765      +/-   ##
==========================================
- Coverage   80.39%   80.38%   -0.02%     
==========================================
  Files         115      115              
  Lines        9879     9883       +4     
  Branches     1513     1514       +1     
==========================================
+ Hits         7942     7944       +2     
  Misses       1415     1415              
- Partials      522      524       +2     
Flag Coverage Δ
integration-tests 41.37% <71.42%> (-0.04%) ⬇️
python-3.10 51.47% <42.85%> (+<0.01%) ⬆️
python-3.11 51.47% <42.85%> (+<0.01%) ⬆️
python-3.12 51.49% <42.85%> (+0.02%) ⬆️
python-3.13 51.49% <42.85%> (+0.05%) ⬆️
python-3.14 53.13% <42.85%> (+0.02%) ⬆️
python-filler-3.12 24.01% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/ctl/importer.py 57.14% <ø> (ø)
infrahub_sdk/node/related_node.py 92.52% <100.00%> (+0.08%) ⬆️
infrahub_sdk/transfer/exporter/json.py 70.96% <100.00%> (-0.91%) ⬇️
infrahub_sdk/transfer/importer/json.py 76.92% <100.00%> (+0.16%) ⬆️
infrahub_sdk/graphql/renderers.py 92.04% <75.00%> (-0.82%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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