-
Notifications
You must be signed in to change notification settings - Fork 6
fix improperly escaped special characters in HFID
#547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change adds a changelog entry documenting a fix for escaping special characters in hfid fields and other strings in GraphQL mutations. In infrahub_sdk/graphql.py, json is imported and convert_to_graphql_as_string now uses json.dumps(value) for JSON-compatible string escaping instead of manual quoting (f""{value}""). Handling for null, Enum, booleans, lists, and BaseModel remains unchanged. No exported/public API signatures were modified. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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. Comment |
Deploying infrahub-sdk-python with
|
| Latest commit: |
4ec8102
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://319a0365.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://bkr-fix-hfid-double-quotes.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #547 +/- ##
=======================================
Coverage 75.59% 75.59%
=======================================
Files 100 100
Lines 8891 8892 +1
Branches 1750 1750
=======================================
+ Hits 6721 6722 +1
Misses 1688 1688
Partials 482 482
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
changelog/+escape-hfid.fixed.md (1)
1-1: Tighten wording and style (capitalization + period).Minor polish for consistency with the PR title and house style.
-- Fixed issue with improperly escaped special characters in `hfid` fields and other string values in GraphQL mutations by implementing proper JSON-style string escaping +- Fixed improperly escaped special characters in `HFID` fields and other string values in GraphQL mutations by implementing JSON‑style string escaping.infrahub_sdk/graphql.py (2)
22-24: Avoid unnecessary ASCII-escaping of Unicode.json.dumps defaults to ensure_ascii=True, which turns non‑ASCII into \uXXXX. GraphQL accepts raw Unicode; keeping it improves readability and reduces diff noise.
- return json.dumps(value) + return json.dumps(value, ensure_ascii=False)
15-16: Make variable references explicit; avoid magic “$”-prefix heuristic.Treating any user string starting with “$” as a variable reference is ambiguous and can misrender legitimate values. Prefer an explicit sentinel type.
+class VarRef(str): + """Explicit GraphQL variable reference wrapper.""" + pass ... - if isinstance(value, str) and value.startswith("$"): - return value + if isinstance(value, VarRef): + return str(value)If you want, I can add a minimal VarRef usage example and tests for both VarRef("$id") and a literal "$acct-001".
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
changelog/+escape-hfid.fixed.md(1 hunks)infrahub_sdk/graphql.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method
Files:
infrahub_sdk/graphql.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: unit-tests (3.10)
- GitHub Check: unit-tests (3.11)
- GitHub Check: unit-tests (3.12)
- GitHub Check: unit-tests (3.13)
- GitHub Check: integration-tests-latest-infrahub
🔇 Additional comments (1)
infrahub_sdk/graphql.py (1)
22-24: Correct fix: use json.dumps for GraphQL string escaping.This removes ad‑hoc quoting and correctly handles quotes, backslashes, control chars, and Unicode.
Fixed issue with improperly escaped special characters in
hfidfields and other string values in GraphQL mutations by implementing proper JSON-style string escapingSummary by CodeRabbit