Silent undefined from k6/experimental/secrets.get() masks missing credentials until request failure
0 reputation · 04 Sept 2023, 10:25 UTC
Context
The k6/experimental/secrets module (introduced in v0.35) reads a local JSON file at VU initialization and exposes secrets.get(name). When a requested key is absent, the function returns undefined without throwing or logging a warning.
Problem
This silent failure propagates into HTTP calls as malformed headers or query parameters, producing generic 401/400 responses that are difficult to trace back to a missing secret. In distributed execution, the secrets file must exist on every load-generator node, and a missing file on any single agent yields the same undefined behavior without a clear diagnostic.
Constraints
- The module remains experimental with no graduation timeline; API changes are possible.
- No built-in validation hook exists to fail fast at script startup.
- Environment variables set via
--envsuffer from the same silentundefinedaccess via__ENV.
Questions
- Is there a recommended pattern to validate all required secrets at VU init and abort the test with a clear message?
- Does the k6 roadmap indicate whether
k6/experimental/secretswill gain a strict mode or explicit error for missing keys? - How do teams using distributed
k6-operatordeployments verify secret propagation across all pods before the main test starts?