Skip to content

feat(ADDON-87180): introduce dedicated index_name validator type#2042

Merged
artemrys merged 10 commits into
developfrom
feat/ADDON-87180-index-name-validator
Jun 5, 2026
Merged

feat(ADDON-87180): introduce dedicated index_name validator type#2042
artemrys merged 10 commits into
developfrom
feat/ADDON-87180-index-name-validator

Conversation

@okashaev-splunk

@okashaev-splunk okashaev-splunk commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the two-validator combination (regex pattern + string length) for
    Splunk index name validation with a single dedicated index_name validator type
  • Adds IndexNameValidator Zod schema registered in AllValidators and AnyOfValidators
  • Adds IndexNameValidator in validator_builder.py that generates validator.IndexName()
  • Updates IndexEntity.long_form() and migrateIndexTypeEntity() to emit {"type": "index_name"}
  • Adds IndexNameValidator definition to schema.json and registers it in AnyValidator and SingleSelectEntity validators
  • Updates expected REST handler fixtures to emit validator.IndexName()
  • Updates test addon globalConfig.json to use index_name validator type
  • Bumps splunktaucclib minimum version to 8.2.0 which ships validator.IndexName()

Note: No UI-side case 'index_name' is needed — backend validation on save is the intended contract for this flow.

Test plan

  • Existing unit tests for IndexEntity updated and passing
  • New validator_builder test case added with golden file validator_builder_result_index_name
  • schema.json updated — Python schema validation accepts {"type": "index_name"}
  • Expected REST handler fixtures updated to emit validator.IndexName()
  • Test addon globalConfig.json updated to use index_name validator
  • splunktaucclib minimum version bumped to 8.2.0

🤖 Generated with Claude Code

Replace the two-validator combination (regex + string length) used for
Splunk index name validation with a single dedicated `index_name` validator
type. This simplifies the globalConfig schema and generated REST handler
code, and makes the intent explicit.

- Add `IndexNameValidator` Zod schema and register it in `AllValidators`
- Add `IndexNameValidator` class in `validator_builder.py` generating `validator.IndexName()`
- Update `IndexEntity.long_form()` and `migrateIndexTypeEntity` to emit `{"type": "index_name"}`
- Add testdata golden file and update unit tests accordingly

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@okashaev-splunk
okashaev-splunk marked this pull request as ready for review June 2, 2026 14:21
@okashaev-splunk
okashaev-splunk requested review from a team as code owners June 2, 2026 14:21

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

Requesting changes. This introduces a new validator contract across backend generation, Python schema, frontend runtime validation, bundled UI assets, and splunktaucclib runtime support, but the PR only wires part of that surface. Several paths now either silently skip validation or generate handler code that the currently required runtime library does not provide.

errorMsg: 'Length of index name should be between 1 and 80.',
},
],
validators: [{ type: 'index_name' }],

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.

Blocking: the UI runtime validator does not handle index_name. ui/src/util/Validator.ts switches over validator types but has no case 'index_name', so after this migration the old regex/string checks are removed and invalid index names are silently accepted in the form. Please add runtime validation and tests for valid/invalid index values before replacing the old validators.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No UI left intentionally, this means no validation will be done during field edit. However when user tries to save the form backend validation is triggered not letting to close from with save operation.
Keeping regexes in UI makes central validation endpoint useless UI validation will always come before backend

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.

Thanks, backend-only validation on save is acceptable for this flow. No need to add a frontend case 'index_name' or duplicate the index-name checks in the UI if this is the intended contract.

Comment thread ui/src/types/globalConfig/baseSchemas.ts
Comment thread tests/unit/commands/rest_builder/test_validator_builder.py
Comment thread tests/unit/entity/test_index_entity.py
- Add IndexNameValidator to schema.json definitions and AnyValidator
- Update expected REST handler fixtures to emit validator.IndexName()
- Fix test function names from test_interval_* to test_index_*

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@okashaev-splunk
okashaev-splunk requested a review from a team as a code owner June 3, 2026 11:28
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jun 3, 2026
artemrys
artemrys previously approved these changes Jun 3, 2026
Replace the old explicit string validator with the new dedicated
index_name validator type in the everything test addon globalConfig.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
],
"additionalProperties": false
},
"IndexNameValidator": {

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.

This adds index_name as a schema-level validator type, but the docs still describe the old contract. docs/entity/components.md says the index field has two internal validators (regex + length), and docs/entity/validators.md does not document index_name even though it is now accepted by AnyValidator. Please update the docs so users know whether index_name is public and so the index component documentation matches the generated config.

wtobis-splunk
wtobis-splunk previously approved these changes Jun 4, 2026
Required for validator.IndexName() support introduced in splunktaucclib 8.2.0.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code Coverage ⚠️

Type PR Develop Change Status
Line Coverage 94.35% 94.38% 0.04% 🔴 Decreased
Branch Coverage 90.66% 90.66% 0.00% ⚪ Unchanged

@artemrys
artemrys merged commit 8e1bf67 into develop Jun 5, 2026
@artemrys
artemrys deleted the feat/ADDON-87180-index-name-validator branch June 5, 2026 14:05
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants