Skip to content

[Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow#260337

Merged
dominiqueclarke merged 4 commits intoelastic:mainfrom
dominiqueclarke:bug/rule-name-validation
Apr 1, 2026
Merged

[Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow#260337
dominiqueclarke merged 4 commits intoelastic:mainfrom
dominiqueclarke:bug/rule-name-validation

Conversation

@dominiqueclarke
Copy link
Copy Markdown
Contributor

@dominiqueclarke dominiqueclarke commented Mar 30, 2026

Summary

Discover.-.Elastic.5.webm
  • Reject "Untitled rule" as a valid name: The placeholder text is now treated as invalid, ensuring users provide a meaningful rule name before saving.
  • Scroll error callout into view: When form validation fails (in both the page and flyout), the error callout now auto-scrolls into the viewport so the user sees immediate feedback.
  • Move error callout above the name field: The validation summary now renders above the rule name for better visibility.

Closes elastic/rna-program#236

Changes

Rule form package (@kbn/alerting-v2-rule-form):

  • form/constants.ts — Added shared DEFAULT_RULE_NAME constant
  • form/fields/name_field.tsx — Custom validate rule rejecting both empty names ("Name is required.") and the placeholder "Untitled rule" ("Please provide a unique rule name.")
  • flyout/error_callout.tsx — Added useRef + useEffect to scrollIntoView() on error, guarded with optional chaining for test environments
  • form/rule_form.tsx — Moved ErrorCallOut from GuiRuleForm to RuleFormContent, rendering above the NameField
  • form/gui_rule_form.tsx — Removed ErrorCallOut (moved to parent)
  • flyout/rule_form_flyout.tsx — Added data-test-subj="ruleV2FlyoutSaveButton" to the flyout save button
  • index.ts — Exported DEFAULT_RULE_NAME

Tests:

  • Updated Jest tests for name_field, error_callout, and use_form_defaults
  • Added Scout UI tests for both the dedicated rule authoring page and the Discover flyout

Test plan

  • Navigate to the rule create page — verify "Untitled rule" is shown as placeholder
  • Click Save without changing the name — verify "Name is required." error appears above the name
  • Type "Untitled rule" as the name and save — verify "Please provide a unique rule name." error
  • Type a real name and save — verify no name validation errors
  • Open the rule form flyout from Discover (ES|QL mode → Rules menu → Create v2 ES|QL rule) — verify same validation behavior
  • In the flyout, scroll down and click Save with invalid name — verify error callout scrolls into view

Addresses rule name validation inconsistencies between the page and flyout
forms. "Untitled rule" is now rejected as a placeholder name, empty names
show a clear error, and the error callout scrolls into view when validation
fails in the flyout. Also moves the error callout above the name field so
it is immediately visible.

Closes elastic/rna-program#236

Made-with: Cursor
@dominiqueclarke dominiqueclarke requested a review from a team as a code owner March 30, 2026 19:11
@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Mar 30, 2026
@dominiqueclarke dominiqueclarke changed the title Fix rule name validation and error visibility in create/edit flow [Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow Mar 30, 2026
@dominiqueclarke dominiqueclarke added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting 9.4.0 bug Fixes for quality problems that affect the customer experience labels Mar 30, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Mar 30, 2026

Approvability

Verdict: Needs human review

This PR adds form validation to prevent saving rules with empty or default placeholder names, and improves error visibility by scrolling validation errors into view. While the changes are straightforward bug fixes with good test coverage, the author does not own any of the modified files — all are owned by @elastic/rna-project-team, who should review these changes.

You can customize Macroscope's approvability policy. Learn more.

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Mar 31, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #3 / GuiRuleForm basic rendering renders ErrorCallOut
  • [job] [logs] Jest Tests #3 / GuiRuleForm basic rendering renders ErrorCallOut
  • [job] [logs] Jest Tests #3 / GuiRuleForm field group ordering renders field groups in correct order
  • [job] [logs] Jest Tests #3 / GuiRuleForm field group ordering renders field groups in correct order
  • [job] [logs] Jest Tests #3 / GuiRuleForm field group ordering still renders ConditionFieldGroup when query editor is excluded
  • [job] [logs] Jest Tests #3 / GuiRuleForm field group ordering still renders ConditionFieldGroup when query editor is excluded
  • [job] [logs] affected Scout: [ platform / alerting_v2 ] plugin / local-stateful-classic - Rule name validation — dedicated page - error callout scrolls into view on failed submission
  • [job] [logs] affected Scout: [ platform / alerting_v2 ] plugin / local-stateful-classic - Rule name validation — dedicated page - error callout scrolls into view on failed submission
  • [job] [logs] affected Scout: [ platform / alerting_v2 ] plugin / local-stateful-classic - Rule name validation — dedicated page - rejects "Untitled rule" as an explicit name
  • [job] [logs] affected Scout: [ platform / alerting_v2 ] plugin / local-stateful-classic - Rule name validation — dedicated page - rejects "Untitled rule" as an explicit name

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/alerting-v2-rule-form 60 61 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
alertingVTwo 277.6KB 278.0KB +404.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
alertingVTwo 140.1KB 140.2KB +145.0B
Unknown metric groups

API count

id before after diff
@kbn/alerting-v2-rule-form 102 103 +1

History

Copy link
Copy Markdown
Contributor

@ana-davydova ana-davydova left a comment

Choose a reason for hiding this comment

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

Tested and reviewed the code!

@dominiqueclarke dominiqueclarke merged commit c151a1f into elastic:main Apr 1, 2026
21 checks passed
@dominiqueclarke dominiqueclarke deleted the bug/rule-name-validation branch April 1, 2026 20:24
mbondyra added a commit to mbondyra/kibana that referenced this pull request Apr 1, 2026
…heck

* commit '6f040b29a5220ce12886a9731f656613e50aff06': (34 commits)
  [Entity Analytics] Add entity resolution UI to service flyout (elastic#260504)
  [Dashboard] Fix setState in embeddables (elastic#260082)
  [EDR Workflows] Unskip FTR tests that failed due to transient Fleet service unavailability (elastic#260519)
  [Observability:Streams] Fix query streams error handling test (elastic#260777)
  [Alerting v2] Dispatcher grouping modes, throttle strategies, and matcher autosuggestion (elastic#260249)
  [Dashboard] State extraction as a consistent override (elastic#259839)
  [Alerting v2] [Rule authoring] Fix rule name validation and error visibility in create/edit flow (elastic#260337)
  [Fix] re-introduce sln breadcrumbs to unified rules (elastic#260289)
  [Security Solution][Endpoint] Updated kibana docs to include `xpack.securitySolution.maxEndpointScriptFileSize` as configurable in cloud (elastic#260568)
  [Alerting v2] updated the alerting-v2-constants package with artifacts constants, fix to the runbook max characters (elastic#260342)
  [Automatic Import V2] Provide user tooltips (elastic#260725)
  [One Workflow] Deduplicate step types by base type in workflow list (elastic#260763)
  [Security Solution] Execution results UI: Enable the feature flag (elastic#260711)
  [Metrics][Discover] internal/search/esql_async returns 200 but METRICS_INFO responds with error (elastic#260746)
  Collapse redundant anyOf/oneOf array unions in OAS query params (elastic#260585)
  [Unified rules] Hide stack rules from global search (elastic#260088)
  [Agent Builder] Sidebar navigation updates (elastic#260728)
  [* As Code] Use PUT for upserts (elastic#260318)
  Update EUI to v114.0.0 (elastic#259497)
  [Entity Resolution] Add contextual-security-apps as co-owner of resolution paths (elastic#260659)
  ...

# Conflicts:
#	src/platform/plugins/shared/dashboard/public/index.ts
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
…ibility in create/edit flow (elastic#260337)

## Summary

[Discover - Elastic
(5).webm](https://github.com/user-attachments/assets/b517a3fc-6a1b-47fa-9754-7ca8d61e352d)

- **Reject "Untitled rule" as a valid name**: The placeholder text is
now treated as invalid, ensuring users provide a meaningful rule name
before saving.
- **Scroll error callout into view**: When form validation fails (in
both the page and flyout), the error callout now auto-scrolls into the
viewport so the user sees immediate feedback.
- **Move error callout above the name field**: The validation summary
now renders above the rule name for better visibility.

Closes elastic/rna-program#236

### Changes

**Rule form package** (`@kbn/alerting-v2-rule-form`):
- `form/constants.ts` — Added shared `DEFAULT_RULE_NAME` constant
- `form/fields/name_field.tsx` — Custom `validate` rule rejecting both
empty names ("Name is required.") and the placeholder "Untitled rule"
("Please provide a unique rule name.")
- `flyout/error_callout.tsx` — Added `useRef` + `useEffect` to
`scrollIntoView()` on error, guarded with optional chaining for test
environments
- `form/rule_form.tsx` — Moved `ErrorCallOut` from `GuiRuleForm` to
`RuleFormContent`, rendering above the `NameField`
- `form/gui_rule_form.tsx` — Removed `ErrorCallOut` (moved to parent)
- `flyout/rule_form_flyout.tsx` — Added
`data-test-subj="ruleV2FlyoutSaveButton"` to the flyout save button
- `index.ts` — Exported `DEFAULT_RULE_NAME`

**Tests:**
- Updated Jest tests for `name_field`, `error_callout`, and
`use_form_defaults`
- Added Scout UI tests for both the dedicated rule authoring page and
the Discover flyout

## Test plan

- [x] Navigate to the rule create page — verify "Untitled rule" is shown
as placeholder
- [x] Click Save without changing the name — verify "Name is required."
error appears above the name
- [x] Type "Untitled rule" as the name and save — verify "Please provide
a unique rule name." error
- [x] Type a real name and save — verify no name validation errors
- [x] Open the rule form flyout from Discover (ES|QL mode → Rules menu →
Create v2 ES|QL rule) — verify same validation behavior
- [x] In the flyout, scroll down and click Save with invalid name —
verify error callout scrolls into view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:skip This PR does not require backporting bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants