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

@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
@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.

/**
* 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} {

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.
@jaydgoss jaydgoss force-pushed the jaygoss/new-700-display-complication-errors-for-uptime-assertion-fields branch from 1c61b59 to 5fba1f3 Compare January 26, 2026 19:09
- 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 force-pushed the jaygoss/new-700-display-complication-errors-for-uptime-assertion-fields branch from 5fba1f3 to a11387c Compare January 26, 2026 19:14
@jaydgoss jaydgoss merged commit 7389a57 into master Jan 26, 2026
53 checks passed
@jaydgoss jaydgoss deleted the jaygoss/new-700-display-complication-errors-for-uptime-assertion-fields branch January 26, 2026 20:32
dashed pushed a commit that referenced this pull request Jan 26, 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
JonasBa pushed a commit that referenced this pull request Jan 27, 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
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