[BUG] Targeting can't select variants whose names contain `&`, `<`, `>`, `\` or `"`
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start in core/pkg/evaluator/json.go at evaluateVariant, where the issue identifies JSON encoding and manual quote removal as the cause. Reproduce the case with a variant name containing escaped characters and compare the resolved variant with the expected TARGETING_MATCH result. The issue links an open pull request for this fix.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Observed behavior
When a targeting rule returns the name of a variant that contains &, <, >, \ or ", the evaluation fails with GENERAL and flagd logs invalid or missing variant. The variant exists in the flag definition, and the same variant works as defaultVariant.
The cause is in evaluateVariant (core/pkg/evaluator/json.go). The JsonLogic result is written with json.NewEncoder, which escapes HTML characters by default (& becomes \u0026, < becomes \u003c). It also escapes \ and ". flagd then removes the quotes from the encoded string by hand and doesn't decode the escapes. As a result, "R&D" is looked up as R\u0026D.
Expected behavior
A targeting rule that returns a valid variant name resolves to that variant with reason TARGETING_MATCH, whatever characters the name contains.
Steps to reproduce
-
Save this as
flags.json:{ "flags": { "team": { "state": "ENABLED", "variants": { "off": "off", "R&D": "rd" }, "defaultVariant": "off", "targeting": { "if": [{ "==": [{ "var": "dept" }, "rd"] }, "R&D", "off"] } } } } -
Start flagd:
flagd start -f file:flags.json. -
Evaluate the flag:
curl -X POST -H "Content-Type: application/json" \ -d '{"flagKey":"team","context":{"dept":"rd"}}' \ http://localhost:8013/flagd.evaluation.v1.Service/ResolveString -
The response is a
GENERALerror instead of{"value":"rd","variant":"R&D","reason":"TARGETING_MATCH"}.
- Lingua principale
- Go
- Stelle
- 1k
- Fork
- 151
- Merge medio
- 5g 5h
- PR unite (30g)
- 14
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di open-feature/flagd
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
open-feature/flagd#2041 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
open-feature/flagd#2134 ·
I maintainer di solito rispondono entro 1 giorno
-
feat: bound resource usage when processing sync source payloadsForse già presa @andrearcaina l’ha presa 4 giorni fa. Apertagood first issue help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 46/100
open-feature/flagd#2133 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feat: consistent opt-in strict schema validation modeForse di nuovo libera @Anurag-S1ngh l’ha presa 29 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
open-feature/flagd#2112 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] kubernetes sync: watch errors bypass flagd's logger and metricsForse già presa @Hrushikesh-ramilla l’ha presa 32 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
open-feature/flagd#2104 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di open-feature/flagd
Issue simili
-
enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Windows系统上,希望复制路径增加 Unix 格式Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
go good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure/prometheus-collector#1828 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni