feat(ADDON-87180): introduce dedicated index_name validator type#2042
Conversation
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>
wtobis-splunk
left a comment
There was a problem hiding this comment.
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' }], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
- 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>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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": { |
There was a problem hiding this comment.
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.
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>
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 |
Summary
Splunk index name validation with a single dedicated
index_namevalidator typeIndexNameValidatorZod schema registered inAllValidatorsandAnyOfValidatorsIndexNameValidatorinvalidator_builder.pythat generatesvalidator.IndexName()IndexEntity.long_form()andmigrateIndexTypeEntity()to emit{"type": "index_name"}IndexNameValidatordefinition toschema.jsonand registers it inAnyValidatorandSingleSelectEntityvalidatorsvalidator.IndexName()globalConfig.jsonto useindex_namevalidator typesplunktaucclibminimum version to8.2.0which shipsvalidator.IndexName()Test plan
IndexEntityupdated and passingvalidator_buildertest case added with golden filevalidator_builder_result_index_nameschema.jsonupdated — Python schema validation accepts{"type": "index_name"}validator.IndexName()globalConfig.jsonupdated to useindex_namevalidatorsplunktaucclibminimum version bumped to8.2.0🤖 Generated with Claude Code