Repository navigation
Fix: The agent version page exported an incorrect DSL format. - #17736
Conversation
📝 WalkthroughWalkthroughThe change adds shared DSL sanitization and download utilities. Agent JSON export and version download now use the complete DSL, clear sensitive API keys, normalize globals, and use the provided title for the JSON filename. ChangesDSL Export
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/pages/agent/utils/clear-sensitive-fields.ts`:
- Around line 37-50: Update the sensitive-field sanitization logic in
clear-sensitive-fields.ts to clear data.form.api_key when data.label matches
either Querit operators or any configured apiKeyOperators, including
TavilySearch. In clear-sensitive-fields.test.ts, replace the regression
expectation that preserves the Tavily key with an assertion that the key is
empty.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e1b08e62-39db-4668-8d59-fd392778cebc
📒 Files selected for processing (5)
web/src/pages/agent/hooks/use-export-json.tsweb/src/pages/agent/utils/clear-sensitive-fields.test.tsweb/src/pages/agent/utils/clear-sensitive-fields.tsweb/src/pages/agent/utils/download-dsl.tsweb/src/pages/agent/version-dialog/index.tsx
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/pages/agent/utils/clear-sensitive-fields.ts`:
- Around line 37-50: Update the sensitive-field sanitization logic in
clear-sensitive-fields.ts to clear data.form.api_key when data.label matches
either Querit operators or any configured apiKeyOperators, including
TavilySearch. In clear-sensitive-fields.test.ts, replace the regression
expectation that preserves the Tavily key with an assertion that the key is
empty.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e1b08e62-39db-4668-8d59-fd392778cebc
📒 Files selected for processing (5)
web/src/pages/agent/hooks/use-export-json.tsweb/src/pages/agent/utils/clear-sensitive-fields.test.tsweb/src/pages/agent/utils/clear-sensitive-fields.tsweb/src/pages/agent/utils/download-dsl.tsweb/src/pages/agent/version-dialog/index.tsx
🛑 Comments failed to post (1)
web/src/pages/agent/utils/clear-sensitive-fields.ts (1)
37-50: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Sanitize graph-form API keys for all configured operators.
The complete DSL download includes
graph. A node withdata.label: Operator.TavilySearchretainsdata.form.api_key, so the downloaded JSON exposes its credential.
web/src/pages/agent/utils/clear-sensitive-fields.ts#L37-L50: Matchdata.labelagainstapiKeyOperatorsas well as Querit aliases before clearingdata.form.api_key.web/src/pages/agent/utils/clear-sensitive-fields.test.ts#L108-L125: Replace the regression test that preserves the Tavily key with an assertion that the key is empty.As per coding guidelines, “remove tests that protect obsolete behavior.”
📍 Affects 2 files
web/src/pages/agent/utils/clear-sensitive-fields.ts#L37-L50(this comment)web/src/pages/agent/utils/clear-sensitive-fields.test.ts#L108-L125🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/agent/utils/clear-sensitive-fields.ts` around lines 37 - 50, Update the sensitive-field sanitization logic in clear-sensitive-fields.ts to clear data.form.api_key when data.label matches either Querit operators or any configured apiKeyOperators, including TavilySearch. In clear-sensitive-fields.test.ts, replace the regression expectation that preserves the Tavily key with an assertion that the key is empty.Source: Coding guidelines
wangq8
left a comment
There was a problem hiding this comment.
Nice catch and clean refactor. This PR fixes a real bug where the version-history dialog exported only agent.dsl.graph instead of the full canonical DSL.
What was broken
The version dialog was doing:
downloadJsonFile(graph, agent?.title);This was missing:
- Sensitive field sanitization (
clearSensitiveFields— stripsapi_keyetc.) - The
globalswrapper that the canvas export path includes - Non-graph DSL fields (e.g.,
components,globals,path) - The
.jsonfile extension
What the fix does well
- Extracts
downloadDslas a shared utility → single source of truth for DSL export - Moves
clear-sensitive-fieldsfromhooks/toutils/— more appropriate location - Both the canvas export button and the version dialog now produce identical output
- Clean diff: mostly moves/renames + the new shared function
Minor notes
- The
.test.tsand.tsfiles inutils/clear-sensitive-fieldsshow 0 additions / 0 deletions — these are pure renames (hooks/→utils/). This is fine but worth confirming the import paths inside those files are updated (they appear to be export-only utility files, so likely no internal import changes needed).
Verdict
LGTM. The fix is correct, the refactor reduces duplication, and both export paths now emit the same (sanitized) DSL format. Approve.
Summary
Fix: The agent version page exported an incorrect DSL format.