{"record":{"id":"021a2f3110b52366","repo":"grafana/k6","slug":"no-value","errorCode":null,"errorMessage":"no value","messagePattern":"no value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/secretsource/file/file.go","lineNumber":73,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\ntype fileSecretSource struct {\n\tinternal map[string]string\n\tfilename string\n}\n\nfunc (fss *fileSecretSource) Description() string {\n\treturn fmt.Sprintf(\"file source from %s\", fss.filename)\n}\n\nfunc (fss *fileSecretSource) Get(key string) (string, error) {\n\tv, ok := fss.internal[key]\n\tif !ok {\n\t\treturn \"\", errors.New(\"no value\")\n\t}\n\treturn v, nil\n}\n","sourceCodeStart":55,"sourceCodeEnd":77,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/secretsource/file/file.go#L55-L77","documentation":"Returned by the file-based secret source's Get(key) when the requested key is not present in the parsed file (fss.internal map lookup fails). The file secret source loads a flat key-value file (JSON/YAML, via --secret-source=file=...) into memory, and any key absent from it yields this generic error.","triggerScenarios":"Calling secret('db_password') when the secrets file contains no db_password entry; key typos or case mismatches (DB_PASSWORD vs db_password); pointing --secret-source=file at the wrong file or a file whose top-level structure nests the keys under another object so the flat map misses them; referencing a key added to a different environment's file.","commonSituations":"Dev/prod secrets files drifting out of sync; renaming a secret in the app but not in the file; YAML indentation mistakes putting keys under a nested parent; using an OS path vs key confusion in CI.","solutions":["Add the missing key to the secrets file with the exact spelling/case used in secret(...)","Verify the file passed via --secret-source=file=... is the one you edited, and re-run with k6 log level debug to see which source is consulted","Flatten nested structures: the lookup is a flat map, so {secrets: {key: val}} will not expose 'key'","List expected keys next to the file (or in CI validation) and diff them before the run"],"exampleFix":"# before\n# secrets.json: {\"db_user\": \"admin\"}\nk6 run -l debug --secret-source=file=secrets.json script.js  # secret('db_password') -> no value\n\n# after\n# secrets.json: {\"db_user\": \"admin\", \"db_password\": \"s3cr3t\"}\nk6 run -l debug --secret-source=file=secrets.json script.js","handlingStrategy":"validation","validationCode":"# Diff required keys against the file before running:\njq -r 'keys[]' secrets.json | sort > /tmp/have\nprintf 'db_user\\ndb_password\\n' | sort > /tmp/want\nmissing=$(comm -13 /tmp/have /tmp/want)\n[ -z \"$missing\" ] || { echo \"secrets file missing: $missing\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a canonical list of secret keys next to the script and validate the file against it in CI","Use identical key names in script and file; avoid case variants","Keep the secrets file flat; the source does a flat map lookup"],"tags":["k6","secrets","file","key-not-found","config"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}