Skip to content

Fix position parser for base pointer options#5574

Open
chrismooreproductions wants to merge 1 commit intografana:masterfrom
chrismooreproductions:fix/position-base-pointer-options-parser
Open

Fix position parser for base pointer options#5574
chrismooreproductions wants to merge 1 commit intografana:masterfrom
chrismooreproductions:fix/position-base-pointer-options-parser

Conversation

@chrismooreproductions
Copy link

Fixes an incorrect error check in parsing logic

Closes #4429

What?

Fixes an incorrect error check in the parser code for the position option, with an example of the correct functionality.

Why?

As in #4429, the position options weren't being correctly parsed meaning tap() always tapped at position (0,0).

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #4429

@chrismooreproductions chrismooreproductions requested a review from a team as a code owner January 20, 2026 14:03
@chrismooreproductions chrismooreproductions requested review from AgnesToulet and oleiade and removed request for a team January 20, 2026 14:03
@CLAassistant
Copy link

CLAassistant commented Jan 20, 2026

CLA assistant check
All committers have signed the CLA.

} finally {
await page.close()
}
}

Choose a reason for hiding this comment

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

I don't think this example is technically required, but it looks like we don't have explicit tests for the element handle options, and this highlights the working functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer an integration test, or even just a unit test. Since the issue was in the Parse logic maybe we should have a unit test on that, and then an integration test in the tests package to ensure that we don't regress in the future.

Choose a reason for hiding this comment

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

No problem. I may look to expand this PR to cover a few other cases as discussed in #4413, and I had a thought that I can introduce some unit tests along the way.

Leave it with me (and thanks for the review 🫶)

Choose a reason for hiding this comment

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

Hi @ankur22 , hope you are well!

Sorry for the delay, I have pushed the suggested changes and deleted this file.

If you could review when you get that chance that would be fab.

Thanks!

Chris

@chrismooreproductions chrismooreproductions changed the title Draft: Fix position parser for base pointer options Fix position parser for base pointer options Jan 20, 2026
@oleiade oleiade requested a review from ankur22 January 22, 2026 14:18
@oleiade
Copy link
Contributor

oleiade commented Jan 22, 2026

@Ankur I'll dismiss myself in your favor as you opened that issue if that's okay with you 🙇🏻

var p map[string]float64
o.Position = &Position{}
if rt.ExportTo(opts.Get(k), &p) != nil {
if rt.ExportTo(opts.Get(k), &p) == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like easy fixes 😄 Thanks!

Copy link
Author

@chrismooreproductions chrismooreproductions Jan 23, 2026

Choose a reason for hiding this comment

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

Ha!

I went down a bit of a rabbit hole with the sobek types but the fix was simple in the end :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@ankur22 Shouldn't we follow the same pattern as in the other functions and return the error if it's not nil?
Something like (not applicable directly as I moved line 190 after the error check:

Suggested change
if rt.ExportTo(opts.Get(k), &p) == nil {
if err := rt.ExportTo(opts.Get(k), &p); err != nil {
return fmt.Errorf("parsing element handle base pointer option position: %w", err)
}
o.Position = &Position{}
o.Position.X = p["x"]
o.Position.Y = p["y"]

Copy link
Contributor

@ankur22 ankur22 Jan 23, 2026

Choose a reason for hiding this comment

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

Yes correct! Good spot! @chrismooreproductions please take a look at what @AgnesToulet has pointed out. You should be able to find other examples in the codebase where we are doing this, as well as the suggestion itself.

Choose a reason for hiding this comment

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

N/P thanks Agnes! I will fix this up and get back to you shortly

Choose a reason for hiding this comment

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

Hey guys sorry for the delay on this, I have pushed the suggested change. Nice catch Agnes :)

Copy link
Contributor

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look and fixing the issue!

I think it's worth adding a couple of tests to encapsulate this behaviour and avoid regressions.

@chrismooreproductions chrismooreproductions force-pushed the fix/position-base-pointer-options-parser branch from fe18489 to 0d24d9e Compare February 13, 2026 20:35
Fixes an incorrect error check in parsing logic

Closes grafana#4429
@chrismooreproductions chrismooreproductions force-pushed the fix/position-base-pointer-options-parser branch from 0d24d9e to 286fe2b Compare February 13, 2026 20:49
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.

tap position option doesn't offset the position as requested

5 participants