grafana/k6 · error · ErrNameContainsGroupSeparator

group and check names may not contain '::'

Error message

group and check names may not contain '::'

What it means

ErrNameContainsGroupSeparator (lib/models.go:29) is returned by lib.NewGroup and lib.NewCheck when the requested name contains '::'. '::' (GroupSeparator, line 22) is reserved: group IDs are built by joining the group hierarchy path with '::' (e.g. group('a') then group('b') inside it yields id 'a::b'), so allowing it inside a name would corrupt path semantics for Group.FindByPath and metric tagging.

Source

Thrown at lib/models.go:29

	"time"

	"gopkg.in/guregu/null.v3"

	"go.k6.io/k6/v2/lib/types"
)

// GroupSeparator for group IDs.
const GroupSeparator = "::"

// RootGroupPath is the id of the root group
//
// Note(@mstoykov): the constant shouldn't be used in all tests in order to not couple the tests too much with it.
// Changing this will be a breaking change and in this way it will be more obvious.
const RootGroupPath = ""

var (
	// ErrNameContainsGroupSeparator is emitted if you attempt to instantiate a Group or Check that contains the separator.
	ErrNameContainsGroupSeparator = errors.New("group and check names may not contain '" + GroupSeparator + "'")

	// ErrCheckGroupIsNil is emitted if you attempt to instantiate a Check (see NewCheck) with a nil Group.
	ErrCheckGroupIsNil = errors.New("check's group must not be nil")
)

// StageFields defines the fields used for a Stage; this is a dumb hack to make the JSON code
// cleaner. pls fix.
type StageFields struct {
	// Duration of the stage.
	Duration types.NullDuration `json:"duration"`

	// If Valid, the VU count will be linearly interpolated towards this value.
	Target null.Int `json:"target"`
}

// A Stage defines a step in a test's timeline.
type Stage StageFields

View on GitHub (pinned to 93accf6570)

Solutions

  1. Remove '::' from the group/check name; use a single '-' or '_' separator instead
  2. If hierarchy is the goal, nest group() calls — the path is joined with '::' automatically: group('api', () => { group('v2', ...) }) yields 'api::v2'

Example fix

// before
group('api::users', () => { http.get('https://test.k6.io/users'); });

// after
group('api', () => {
  group('users', () => { http.get('https://test.k6.io/users'); });
});
Defensive patterns

Strategy: validation

Validate before calling

// Guard names before calling group()/check()
const safeName = (n) => {
  if (n.includes('::')) throw new Error(`name must not contain '::': ${n}`);
  return n;
};
group(safeName(userDefined), () => { /* ... */ });

Prevention

When it happens

Trigger: Calling group('login::slow') or check(res, { 'a::b': r => r.ok }) in a k6 script; NewGroup/NewCheck parse the name and return this sentinel error before creating the object.

Common situations: Teams using '::' as a visual namespace separator in names ('api::v2::users'), or porting naming conventions from other tools (RSpec/Rust style) where '::' is idiomatic.

Related errors


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