grafana/k6 · error

no value

Error message

no value

What it means

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.

Source

Thrown at internal/secretsource/file/file.go:73

			}
		}
	}
	return nil
}

type fileSecretSource struct {
	internal map[string]string
	filename string
}

func (fss *fileSecretSource) Description() string {
	return fmt.Sprintf("file source from %s", fss.filename)
}

func (fss *fileSecretSource) Get(key string) (string, error) {
	v, ok := fss.internal[key]
	if !ok {
		return "", errors.New("no value")
	}
	return v, nil
}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Add the missing key to the secrets file with the exact spelling/case used in secret(...)
  2. 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
  3. Flatten nested structures: the lookup is a flat map, so {secrets: {key: val}} will not expose 'key'
  4. List expected keys next to the file (or in CI validation) and diff them before the run

Example fix

# before
# secrets.json: {"db_user": "admin"}
k6 run -l debug --secret-source=file=secrets.json script.js  # secret('db_password') -> no value

# after
# secrets.json: {"db_user": "admin", "db_password": "s3cr3t"}
k6 run -l debug --secret-source=file=secrets.json script.js
Defensive patterns

Strategy: validation

Validate before calling

# Diff required keys against the file before running:
jq -r 'keys[]' secrets.json | sort > /tmp/have
printf 'db_user\ndb_password\n' | sort > /tmp/want
missing=$(comm -13 /tmp/have /tmp/want)
[ -z "$missing" ] || { echo "secrets file missing: $missing"; exit 1; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/021a2f3110b52366. Report an issue: GitHub.