{"record":{"id":"7dcb903fc46f0a52","repo":"crowdsecurity/crowdsec","slug":"s-value-expression-must-be-set","errorCode":null,"errorMessage":"%s: value expression must be set","messagePattern":"(.+?): value expression must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/parser/stash.go","lineNumber":39,"sourceCode":"\tTTL        string `yaml:\"ttl,omitempty\"`\n\tMaxMapSize int    `yaml:\"size,omitempty\"`\n\tStrategy   string `yaml:\"strategy,omitempty\"`\n}\n\ntype RuntimeStash struct {\n\tConfig          *Stash\n\tKeyExpression   *vm.Program\n\tValueExpression *vm.Program\n\tTTLVal          time.Duration\n}\n\nfunc (s *Stash) Validate() error {\n\tif s.Name == \"\" {\n\t\treturn errors.New(\"name must be set\")\n\t}\n\n\tif s.Value == \"\" {\n\t\treturn fmt.Errorf(\"%s: value expression must be set\", s.Name)\n\t}\n\n\tif s.Key == \"\" {\n\t\treturn fmt.Errorf(\"%s: key expression must be set\", s.Name)\n\t}\n\n\tif s.TTL == \"\" {\n\t\treturn fmt.Errorf(\"%s: ttl must be set\", s.Name)\n\t}\n\n\tif s.Strategy == \"\" {\n\t\ts.Strategy = \"LRU\"\n\t}\n\n\t// should be configurable\n\tif s.MaxMapSize == 0 {\n\t\ts.MaxMapSize = 100\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/parser/stash.go#L21-L57","documentation":"Stash.Validate() checks that every stash configuration stanza defines a value expression, which is what gets stored in the stash cache when the stash fires. If `value` is empty the stash has nothing to store, so configuration loading fails with the stash name prefixed for identification.","triggerScenarios":"A `stash:` entry in a parser/enricher stage (or profile) declares `name:` but omits the `value:` expression; Validate() runs during config load (reached e.g. via UsageMetrics validation path).","commonSituations":"Hand-written stash config where the user only set name/key/ttl and forgot `value`; a partially commented-out YAML block that left `value:` with nothing after it.","solutions":["Add a `value:` expr expression to the stash stanza named in the error, e.g. `value: evt.Parsed.src_ip`.","Check for YAML indentation issues that detached the value from the `value:` key.","Re-run `cscli` / restart crowdsec to confirm the stash validates."],"exampleFix":"// before\nstashes:\n  - name: my-stash\n    key: evt.Parsed.src_ip\n    ttl: 1h\n// after\nstashes:\n  - name: my-stash\n    key: evt.Parsed.src_ip\n    value: evt.Parsed.src_ip\n    ttl: 1h","handlingStrategy":"validation","validationCode":"for i, s := range stashes {\n    if s.Value == \"\" { return fmt.Errorf(\"stash[%d] %q: value expression required\", i, s.Name) }\n}","typeGuard":null,"tryCatchPattern":"if err := stash.Validate(); err != nil {\n    return fmt.Errorf(\"invalid stash config: %w\", err)\n}","preventionTips":["Always set name, key, value and ttl together in stash stanzas.","Use a config schema check / YAML lint in CI for parser configs."],"tags":["parser","stash","validation","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}