Skip to content

sanitize index-name does not strip all characters Elasticsearch rejects #324

@MattDevy

Description

@MattDevy

Summary

elastic sanitize index-name lowercases and strips whitespace, but leaves characters that Elasticsearch rejects in index names (e.g. !). The current --help description ("Sanitize an Elasticsearch index or alias name") implies the output is always a valid index name.

Reproducer

$ elastic version
{"version": "0.1.1"}

$ elastic sanitize index-name 'Foo Bar!'
# changes: lowercased, stripped whitespace
foobar!

$ elastic sanitize index-name 'My/Bad:Name*'
# changes: lowercased, stripped forbidden characters
mybadname

The first case still contains !, which Elasticsearch rejects in index names. The second case correctly strips forbidden characters.

Expected behavior

Either:

  • Strip every character that Elasticsearch's index-name validator rejects, so the output is always a valid identifier, or
  • Document the limited guarantee in --help and the stderr "changes" line (e.g. "removes characters known to be invalid; full validation still required").

Environment

  • elastic v0.1.1 (Homebrew on macOS, Darwin 25.5.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions