-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(uptime): Display assertion compilation errors in form #106922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(uptime): Display assertion compilation errors in form #106922
Conversation
There was a problem hiding this 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} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be unknown
| 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.
1c61b59 to
5fba1f3
Compare
- 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
5fba1f3 to
a11387c
Compare
## 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
## 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
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
mapAssertionFormErrorsutility to transform assertion errors into form-friendly format{"assertion": {"error": "...", "details": "..."}}(uptime alerts){"dataSources": {"assertion": {"error": "...", "details": "..."}}}(detector forms)/alerts/rules/uptime/)/detectors/uptime/new/)/detectors/uptime/:id/edit/)Manual Test Plan
Test compilation error in Uptime Alert form:
$[invalid)Test compilation error in Detector form:
Test serialization error:
Fixes NEW-700