Skip to content

Raise a new file not found error when loading queries#950

Merged
ogenstad merged 1 commit intoinfrahub-developfrom
pog-filenotfound-on-load-query
Apr 17, 2026
Merged

Raise a new file not found error when loading queries#950
ogenstad merged 1 commit intoinfrahub-developfrom
pog-filenotfound-on-load-query

Conversation

@ogenstad
Copy link
Copy Markdown
Contributor

@ogenstad ogenstad commented Apr 15, 2026

Why

If a user has an .infrahub.yml file with a query section and the file for one of those queries are missing the error message isn't very helpful. Here we instead catch the file not found error and raise a custom SDK error that the backend will catch.

What changed

  • Add try/except around the loading of a query
  • Add tests

Summary by CodeRabbit

  • New Features

    • Improved error handling for missing repository query files with a dedicated exception that includes the missing file path.
  • Tests

    • Added test coverage for loading GraphQL query files and verifying proper error reporting when files are missing.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3305f85
Status: ✅  Deploy successful!
Preview URL: https://07417e2d.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-filenotfound-on-load-que.infrahub-sdk-python.pages.dev

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc720e40-40a9-44d1-8ee1-958f7bcc8968

📥 Commits

Reviewing files that changed from the base of the PR and between 44a7ccc and 3305f85.

📒 Files selected for processing (3)
  • infrahub_sdk/exceptions.py
  • infrahub_sdk/schema/repository.py
  • tests/unit/sdk/test_schema_repository.py

Walkthrough

This pull request introduces a new exception class RepositoryFileNotFoundError in the exceptions module and integrates it into the GraphQL configuration loader. The new exception accepts a file path and optional message parameter, storing the file path for programmatic access. The InfrahubRepositoryGraphQLConfig.load_query() method was updated to catch FileNotFoundError exceptions and re-raise them as RepositoryFileNotFoundError with the file path information preserved. Unit tests were added to verify the exception is raised correctly when query files are missing and to validate successful file loading behavior.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title accurately and specifically describes the main change: introducing a new file not found error when loading GraphQL queries.
Description check ✅ Passed The description addresses why the change is needed and what changed, but lacks implementation details, testing instructions, and impact assessment sections.

✏️ 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop     #950      +/-   ##
====================================================
+ Coverage             81.09%   81.11%   +0.01%     
====================================================
  Files                   134      134              
  Lines                 11306    11314       +8     
  Branches               1693     1693              
====================================================
+ Hits                   9169     9177       +8     
  Misses                 1594     1594              
  Partials                543      543              
Flag Coverage Δ
integration-tests 41.84% <22.22%> (-0.03%) ⬇️
python-3.10 54.03% <77.77%> (+0.01%) ⬆️
python-3.11 54.03% <77.77%> (+0.03%) ⬆️
python-3.12 54.01% <77.77%> (+0.01%) ⬆️
python-3.13 54.03% <77.77%> (+0.01%) ⬆️
python-3.14 55.61% <77.77%> (+0.01%) ⬆️
python-filler-3.12 22.78% <22.22%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/exceptions.py 89.11% <100.00%> (+0.38%) ⬆️
infrahub_sdk/schema/repository.py 89.88% <100.00%> (+0.17%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad ogenstad marked this pull request as ready for review April 15, 2026 14:29
@ogenstad ogenstad requested a review from a team as a code owner April 15, 2026 14:29
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@ogenstad ogenstad merged commit 5523e94 into infrahub-develop Apr 17, 2026
22 checks passed
@ogenstad ogenstad deleted the pog-filenotfound-on-load-query branch April 17, 2026 14:42
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