Skip to content

Reject multiple k6 scenarios in script validation - #1795

Open
amarkdotdev wants to merge 1 commit into
grafana:mainfrom
amarkdotdev:fix/1741-single-k6-scenario-validation
Open

Reject multiple k6 scenarios in script validation#1795
amarkdotdev wants to merge 1 commit into
grafana:mainfrom
amarkdotdev:fix/1741-single-k6-scenario-validation

Conversation

@amarkdotdev

Copy link
Copy Markdown

Summary

  • Enforce a single k6 scenario in browser and scripted check validation, matching triage guidance that SM only supports one VU/scenario.
  • Return a clear user-facing error when options.scenarios defines more than one scenario, instead of validating only the first.
  • Add unit coverage for multi-scenario rejection in browser and scripted validators.

Fixes #1741

Test plan

  • yarn test src/schemas/forms/script/validation.test.ts
  • In the check editor, paste a browser script with two scenarios and confirm the form shows the single-scenario error
  • Confirm a valid single-scenario browser/scripted check still saves successfully

Synthetic Monitoring only supports a single VU/scenario. Extra scenarios were previously ignored by validation, so invalid options in later scenarios could slip through. Reject scripts that define more than one scenario with a clear error.

Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com>
@amarkdotdev
amarkdotdev requested a review from a team as a code owner August 10, 2026 03:47
@amarkdotdev
amarkdotdev requested review from VikaCep and g3john August 10, 2026 03:47
@cla-assistant

cla-assistant Bot commented Aug 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Aug 10, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6dabac9. Configure here.

(scenario) =>
(scenario.key.type === 'Identifier' || scenario.key.type === 'Literal') &&
scenario.value.type === 'ObjectExpression'
).length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scenario count skips non-literal values

Medium Severity

countScenarios only counts entries whose values are inline ObjectExpressions. Scenario configs referenced by identifier (including shorthand like scenarios: { ui, api }) are ignored, so multi-scenario scripts can pass the new single-scenario check.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6dabac9. Configure here.

@ckbedwell

Copy link
Copy Markdown
Contributor

@amarkdotdev Thanks for your contribution and picking this up! Can you sign the CLA, please? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple k6 scenarios: validation & dashboard metrics

2 participants