grafana/k6 · warning

no value

Error message

no value

What it means

Identical lookup semantics to the file secret source, but returned by the built-in mock secret source used in k6's own tests. mockSecretSource serves a fixed internal map; requesting any key not in that map returns 'no value'. Seeing it in production means a test double leaked into a real run or an embedding is reusing k6's test fixtures.

Source

Thrown at internal/secretsource/mock/mock.go:48

// NewMockSecretSource returns a new secret source mock with the provided name and map of secrets
func NewMockSecretSource(secrets map[string]string) secretsource.Source {
	return &mockSecretSource{
		internal: secrets,
	}
}

type mockSecretSource struct {
	internal map[string]string
}

func (mss *mockSecretSource) Description() string {
	return "this is a mock secret source"
}

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

View on GitHub (pinned to 93accf6570)

Solutions

  1. Seed the mock with the key before Get: mock.New(map[string]string{"api_key": "x"}) or the package's equivalent constructor
  2. Prefer errors.Is / sentinel-error checks over matching the raw 'no value' string in test assertions
  3. Keep internal/secretsource/mock imports confined to _test.go files; audit embedders that ship it in production binaries

Example fix

// before
src := mock.New(map[string]string{})
_, err := src.Get("api_key") // err: no value

// after
src := mock.New(map[string]string{"api_key": "test-value"})
v, err := src.Get("api_key")
Defensive patterns

Strategy: validation

Validate before calling

// In tests: seed every key the test will read before calling Get.
required := []string{"api_key", "db_password"}
for _, k := range required {
    if _, ok := seeded[k]; !ok {
        t.Fatalf("mock secret source not seeded with %q", k)
    }
}

Try / catch

In Go tests, call Get and assert on ok/err separately; use require.NoError with a message naming the key, and treat 'no value' as a fixture bug, not a runtime condition.

Prevention

When it happens

Trigger: Unit/integration tests of secret-source plumbing that call Get() on the mock with an unseeded key; embedding k6 and accidentally importing internal/secretsource/mock in non-test code; test helpers that share one mock instance across cases where earlier tests seed different keys.

Common situations: Writing new tests for secret sources and forgetting to seed the map; refactoring tests so a previously-seeded key is now cleared; asserting on the error string ('no value') which couples tests to the message.

Related errors


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