Skip to content

Conversation

@jaydgoss
Copy link
Member

@jaydgoss jaydgoss commented Jan 23, 2026

Summary

Display assertion compilation/serialization errors from the uptime-checker validator in uptime monitor forms. When an invalid assertion is submitted (e.g., malformed JSON path syntax), the error is now displayed on the Assertions field in the Verification section with a descriptive title.

Changes

  • Add mapAssertionFormErrors utility to transform assertion errors into form-friendly format
  • Handle two API response formats:
    • Direct: {"assertion": {"error": "...", "details": "..."}} (uptime alerts)
    • Nested: {"dataSources": {"assertion": {"error": "...", "details": "..."}}} (detector forms)
  • Add descriptive error titles based on error type:
    • "Compilation Error" - invalid JSON path syntax
    • "Serialization Error" - malformed assertion structure
    • "Validation Error" - fallback for unknown error types
  • Apply error handling to all uptime forms:
    • Uptime Alert create/edit (/alerts/rules/uptime/)
    • Uptime Detector create (/detectors/uptime/new/)
    • Uptime Detector edit (/detectors/uptime/:id/edit/)

Manual Test Plan

  1. Test compilation error in Uptime Alert form:

    • Go to Alerts → Create Alert → Uptime
    • Fill in required fields (project, environment, URL, name)
    • Add a JSON Path assertion with invalid syntax (e.g., $[invalid)
    • Click "Create Rule"
    • Verify error appears on Assertions field: "Compilation Error: ..."
  2. Test compilation error in Detector form:

    • Go to Monitors → New Monitor → Uptime
    • Fill in required fields
    • Add a JSON Path assertion with invalid syntax
    • Click "Create"
    • Verify error appears on Assertions field: "Compilation Error: ..."
  3. Test serialization error:

    • This requires sending a malformed assertion structure (e.g., invalid op type)
    • Can be tested via unit tests or by temporarily modifying the form's onPreSubmit

Fixes NEW-700

Add error handling for assertion compilation/serialization errors from
the uptime-checker validator. When the API returns an error like
`{"assertion": {"error": "compilation_error", "details": "..."}}`,
the form now properly extracts and displays the error message on
the Assertions field in the Verification section.
Add descriptive titles to assertion validation errors based on error type:
- "Compilation Error" for invalid JSON path syntax
- "Serialization Error" for malformed assertion structure
- "Validation Error" as fallback

Also adds test coverage for serialization errors.
@linear
Copy link

linear bot commented Jan 23, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 23, 2026
- Extract assertion error mapping to shared utility (assertionFormErrors.tsx)
- Handle both API response formats:
  - Direct: {"assertion": {"error": "...", "details": "..."}}
  - Nested: {"dataSources": {"assertion": {"error": "...", "details": "..."}}}
- Add mapAssertionFormErrors to detector create/edit forms
- Add comprehensive unit tests for error mapping
@jaydgoss jaydgoss marked this pull request as ready for review January 23, 2026 23:05
@jaydgoss jaydgoss requested review from a team as code owners January 23, 2026 23:05
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

result.assertion = formatAssertionError(result.dataSources.assertion);
// Clean up the nested structure
delete result.dataSources;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting dataSources may lose other error fields

Low Severity

When processing a nested assertion error, delete result.dataSources removes the entire object. If the API response contains other error fields within dataSources (e.g., url or method validation errors alongside the assertion error), those errors would be silently dropped and not displayed to the user. The form sends multiple fields under dataSources (url, method, headers, body, etc.), so if validation errors for these fields are returned nested under dataSources, they would be lost.

Fix in Cursor Fix in Web

/**
* Checks if an object is an assertion error with error type and details.
*/
function isAssertionError(obj: any): obj is {details: string; error: string} {
Copy link
Member

Choose a reason for hiding this comment

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

should this be unknown

Suggested change
function isAssertionError(obj: any): obj is {details: string; error: string} {
function isAssertionError(obj: unknown): obj is {details: string; error: string} {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants