Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

frontend: clean json parsing#270

Merged
alexeykazakov merged 2 commits intocodeready-toolchain:masterfrom
rsoaresd:delete_json_parsing
Feb 12, 2026
Merged

frontend: clean json parsing#270
alexeykazakov merged 2 commits intocodeready-toolchain:masterfrom
rsoaresd:delete_json_parsing

Conversation

@rsoaresd
Copy link
Collaborator

@rsoaresd rsoaresd commented Feb 12, 2026

Description

When manually submmiting an alert like this:

<alert message>

Severity: Medium

Region: us-east-1

Last Seen: February 11th at 1:29 PM

TARSy was not considering Last Seen, since it was trying to parse it as JSON and the key does not consider spaces.

This PR cleans JSON parsing, since we do not intend to support it

Summary by CodeRabbit

  • Improvements
    • Simplified manual alert submission—free-text input now submits as plain text without automatic parsing or data extraction attempts.
    • Removed the AUTO-PARSE badge from the structured input section for a cleaner interface.
    • Updated form messaging to clearly communicate how free-text submissions are handled.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

This change removes the free-text structured-data auto-parsing functionality from the ManualAlertForm component. Free-text submissions now send data as-is without extraction logic, and related UI elements and parsing code are eliminated.

Changes

Cohort / File(s) Summary
Free-Text Parsing Removal
dashboard/src/components/ManualAlertForm.tsx
Removes isStructuredData detection, parseFreeText parser, and associated debug logging. Free-text input now always submits as { message: freeText }. UI copy and AUTO-PARSE badge also removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 No more parsing paths to chase,
Free text flows without a trace,
Plain and simple, message clear,
The form's now lighter, never fear! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'frontend: clean json parsing' accurately summarizes the main change: removing/cleaning JSON parsing logic from the frontend ManualAlertForm component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
dashboard/src/components/ManualAlertForm.tsx (1)

387-462: Consider extracting shared submission logic.

handleFreeTextSubmit and handleKeyValueSubmit (lines 292–382) are nearly identical — they share alert-type validation, runbook SSRF check, alertData assembly (alert_type, runbook, slack_fingerprint, MCP), submission call, error handling, and navigation. Only the data payload differs.

Extracting a common submitAlert(data: Record<string, any>) helper would eliminate ~50 lines of duplication and make future changes (e.g., adding a new field to the payload) less error-prone.

♻️ Sketch
+ const submitAlert = async (data: Record<string, any>) => {
+   setError('');
+   setSuccess('');
+   setLoading(true);
+   try {
+     if (!alertType || alertType.trim().length === 0) {
+       setError('Alert Type is required');
+       return;
+     }
+     if (!isValidRunbookUrl(runbook, availableRunbooks)) {
+       setError('Invalid runbook URL. Only GitHub URLs or approved runbooks are allowed.');
+       return;
+     }
+     const alertData: Record<string, any> = { data };
+     if (alertType.trim() !== defaultAlertType) alertData.alert_type = alertType.trim();
+     if (runbook && runbook !== DEFAULT_RUNBOOK) alertData.runbook = runbook;
+     if (slackMessageFingerprint?.trim()) alertData.slack_message_fingerprint = slackMessageFingerprint.trim();
+     const filteredMCP = filterMCPSelection(mcpSelection);
+     if (filteredMCP) alertData.mcp = filteredMCP;
+     const response = await apiClient.submitAlert(alertData);
+     navigate(`/sessions/${response.session_id}`);
+   } catch (error: any) {
+     const detail = error.response?.data?.detail;
+     setError(typeof detail === 'string' ? detail : detail?.message || 'Failed to submit alert');
+   } finally {
+     setLoading(false);
+   }
+ };

Then each handler just validates its own input and calls submitAlert(payload).

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.71%. Comparing base (8bccc9c) to head (4129711).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #270      +/-   ##
==========================================
- Coverage   83.71%   83.71%   -0.01%     
==========================================
  Files         143      143              
  Lines       13543    13543              
==========================================
- Hits        11338    11337       -1     
- Misses       2205     2206       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexeykazakov alexeykazakov merged commit 74723cf into codeready-toolchain:master Feb 12, 2026
4 of 5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants