Skip to content

fix: anchor gridKeys regex to grid item rows in generated k6#2242

Merged
caalador merged 3 commits into
mainfrom
fix/tighten-regex-for-grid-itemkeys
May 11, 2026
Merged

fix: anchor gridKeys regex to grid item rows in generated k6#2242
caalador merged 3 commits into
mainfrom
fix/tighten-regex-for-grid-itemkeys

Conversation

@tltv
Copy link
Copy Markdown
Member

@tltv tltv commented May 8, 2026

The previous regex /"key":"[^"]+"/g matched both grid item rows ({"key":"1","col0":...}) and change-record keys ({"node":N,"type":"put","key":"highlight",...}). On responses with no grid items it overwrote gridKeys with property names like "highlight" or "tag", causing select() RPCs to send garbage keys and downstream resolveNode() throws (e.g. "unresolved node: abc"). Anchoring on { matches only keys that are the first property of an object, so grid items are picked up and change-record keys are ignored; when no items are present, gridKeys keeps its previous valid contents.

Replace the naive walker in K6ScenarioCombiner. The combiner is now agnostic to braces in human-written comments and string literals.

The previous regex /"key":"[^"]+"/g matched both grid item rows ({"key":"1","col0":...}) and change-record keys ({"node":N,"type":"put","key":"highlight",...}). On responses with no grid items it overwrote gridKeys with property names like "highlight" or "tag", causing select() RPCs to send garbage keys and downstream resolveNode() throws (e.g. "unresolved node: abc"). Anchoring on `{` matches only keys that are the first property of an object, so grid items are picked up and change-record keys are ignored; when no items are present, gridKeys keeps its previous valid contents.

Replace the naive walker in K6ScenarioCombiner. The combiner is now agnostic to braces in human-written comments and string literals.
@tltv tltv requested a review from caalador May 8, 2026 13:19
@tltv
Copy link
Copy Markdown
Member Author

tltv commented May 8, 2026

assertEquals(1, handleSummaryCount,
"Combined script must export exactly one handleSummary. Got:\n"
+ content);
assertTrue(content.contains("export function alphaScenario()"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't really check that the function is correctly wrapped, only that the function export has been added with the file name. should probably check the body given to writeScenario is there, or all the lines are found as full lines.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added scenario wrapper body line asserts.

@caalador caalador enabled auto-merge (squash) May 11, 2026 08:00
@caalador caalador merged commit 372fb22 into main May 11, 2026
11 checks passed
@caalador caalador deleted the fix/tighten-regex-for-grid-itemkeys branch May 11, 2026 08:04
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.

2 participants