Skip to content

RG-T117 View call fix - #448

Merged
ucswift merged 2 commits into
masterfrom
develop
Aug 6, 2026
Merged

RG-T117 View call fix#448
ucswift merged 2 commits into
masterfrom
develop

Conversation

@ucswift

@ucswift ucswift commented Aug 6, 2026

Copy link
Copy Markdown
Member

PR Description

Fixes the "View Call" page to gracefully handle non-formBuilder call form data

Previously, the View Call page always passed CallFormData directly to the formRender plugin expecting valid formBuilder JSON. When the field contained plain text (e.g., from older or external API clients that wrote free text such as a "Submitted..." message), formRender would fail because it could not parse the data as JSON.

Changes

  • Proper serialization: CallFormData is now serialized via JSON.NET with HTML-escape handling and safely null-coalesced to an empty string, rather than being embedded raw inside a JavaScript string literal (which was vulnerable to quote/character escaping issues).
  • JSON validation before rendering: The code attempts to parse the value as JSON and only invokes formRender when the result is a valid JSON array (proper formBuilder data).
  • Fallback display: If CallFormData is not valid formBuilder JSON but still contains text, it is now displayed as plain read-only text inside the container instead of causing a rendering error.

Functional Impact

Users can now reliably view calls whose form data was authored by older or third-party clients that stored plain text rather than structured form definitions, eliminating the form-rendering failure on the View Call screen.

Summary by CodeRabbit

  • Bug Fixes
    • Improved call form rendering by safely handling both current JSON data and legacy content.
    • Invalid or unsupported form data now appears as read-only text instead of preventing the call from rendering.
    • Valid form fields continue to display as disabled fields.

@Resgrid-Bot

Resgrid-Bot commented Aug 6, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@request-info

request-info Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The call view now parses form data safely. Valid formBuilder arrays render escaped labels, descriptions, and option labels as disabled fields. Invalid or legacy content renders as read-only text.

Changes

Call form rendering

Layer / File(s) Summary
Validated call form rendering
Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml
The view adds JSON parsing with error handling. Valid arrays escape API-writable fields before rendering through formBuilder. Invalid or legacy content renders as plain read-only text.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies a fix to the call view, which matches the changes to ViewCall.cshtml.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml`:
- Around line 977-980: Update the formRender invocation in the
Array.isArray(callFormFields) branch to protect API-writable callFormData by
enabling sanitizerOptions and disabling HTML labels, or by allowlisting and
sanitizing the parsed payload before rendering. Ensure labels and paragraph
content are treated as plain text rather than rendered HTML.
- Around line 985-987: Update the success handler’s rendered-form selector to
target `#fb-template` .rendered-form and include button elements alongside input,
textarea, and select, ensuring all controls are made read-only or disabled.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c52c7c5-6958-4e72-aa2f-c318fd7ddaa1

📥 Commits

Reviewing files that changed from the base of the PR and between 8c7ac5f and 756f7b3.

📒 Files selected for processing (1)
  • Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml

Comment thread Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml Outdated
Comment thread Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml
var callFormFields = null;
try {
callFormFields = JSON.parse(callFormData);
} catch (e) { }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

The empty catch block on line 975 swallows the JSON.parse exception silently, leaving no diagnostic trail for malformed CallFormData despite Rule [28] requiring caught exceptions be logged with context. Add a minimal console.warn with the callId inside the catch block.

Kody rule violation: Avoid empty catch blocks

Prompt for LLM

File Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml:

Line 975:

The empty catch block on line 975 swallows the JSON.parse exception silently, leaving no diagnostic trail for malformed CallFormData despite Rule [28] requiring caught exceptions be logged with context. Add a minimal console.warn with the callId inside the catch block.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

} catch (e) { }

if (Array.isArray(callFormFields)) {
// form-render inserts label/option/description content as HTML and its sanitizer is a

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules low

The var declaration of newCallForm violates Rule [37] which requires const/let for variable declarations. Since newCallForm is assigned once and never reassigned, replace var with const.

Kody rule violation: Always use const and let

Prompt for LLM

File Web/Resgrid.Web/Areas/User/Views/Dispatch/ViewCall.cshtml:

Line 978:

The var declaration of newCallForm violates Rule [37] which requires const/let for variable declarations. Since newCallForm is assigned once and never reassigned, replace var with const.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@ucswift

ucswift commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Approve

@ucswift
ucswift merged commit b268bda into master Aug 6, 2026
16 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is approved.

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