fix: reject path-like tenant IDs before WAL join - #7790
Open
SashaMIT wants to merge 1 commit into
Open
Conversation
storage.New already refused an empty tenant because Join plus RemoveAll would wipe the WAL root. A tenant of ".." still escaped to the parent directory. Kafka ingest uses the record key as the tenant and never runs ExtractValidTenantID, so this is the last gate. Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
SashaMIT
requested review from
carles-grafana,
electron0zero,
ie-pham,
javiermolinar,
knylander-grafana,
mapno,
mattdurham,
mdisibio,
ruslan-mikhailov,
stoewer,
yvrhdn,
zalegrala and
zhxiaogg
as code owners
August 18, 2026 18:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
storage.Newalready rejects an empty tenant becausefilepath.Join(cfg.Path, "")plusos.RemoveAllwould wipe the metrics-generator WAL root. A tenant of..still escapes:Joinresolves to the parent ofcfg.Path, thenRemoveAlldeletes that parent.HTTP
PushSpansis already covered.validation.ExtractValidTenantIDgoes throughdskit/tenant.TenantID, which callsValidTenantIDand rejects./..//. Kafka ingest does not.generator_kafka.gotakesstring(r.Key)and callsgetOrCreateInstancewith no tenant check, so a record keyed..still reachesstorage.New.This PR runs the same
dskit/tenant.ValidTenantIDcheck instorage.Newbefore the Join. Empty stays the existing error..,.., and IDs with unsupported characters (including/) returninvalid tenant ID.I used Cursor while writing the change and tests. I reviewed every line and ran the new cases locally.
Which issue(s) this PR fixes:
n/a
Checklist
.chloggen/(runmake chlog-new, ormake chlog-new FILENAME=<name>to override the default branch-name file; see.chloggen/README.md)Made with Cursor