Visitar URL original
Fix the source position of read resources in the Go SDK by iwahbe · Pull Request #24602 · pulumi/pulumi · GitHub
Skip to content

Fix the source position of read resources in the Go SDK - #24602

Merged
iwahbe merged 1 commit into
masterfrom
iwahbe/go-sdk-source-position
Sep 9, 2026
Merged

iwahbe merged 1 commit into
masterfrom
iwahbe/go-sdk-source-position

Conversation

@iwahbe

@iwahbe iwahbe commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Fix how Go reports source positions for <pkg>.Get<resource> functions, matching our TypeScript & Python behavior.

This behavior is tested with a full integration test to ensure our solution matches the SDKs we actually generate. If we add another function call between <pkg>.Get<resource> calls and ctx.ReadResource, this test will fail and we will know to adjust our behavior.

Fixes #24601

@iwahbe

iwahbe commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

This change is part of the following stack:

Change managed by git-spice.

@iwahbe iwahbe changed the title fix disableSSL to only override when no explicit scheme is given (#24593) Fix the source position of registered resources in the Go SDK Sep 9, 2026
@iwahbe
iwahbe force-pushed the iwahbe/go-sdk-source-position branch 2 times, most recently from 3756f55 to 028dfb7 Compare September 9, 2026 11:14
@iwahbe iwahbe changed the title Fix the source position of registered resources in the Go SDK Fix the source position of read resources in the Go SDK Sep 9, 2026
@iwahbe
iwahbe force-pushed the iwahbe/go-sdk-source-position branch from 028dfb7 to 63b290a Compare September 9, 2026 11:15
@iwahbe
iwahbe marked this pull request as ready for review September 9, 2026 11:37
@iwahbe
iwahbe requested a review from a team as a code owner September 9, 2026 11:37
@iwahbe
iwahbe enabled auto-merge September 9, 2026 11:41
The Go SDK sends a source position and a stack trace with every resource
registration and read.  The intended position is the line of user code
that invoked the generated SDK: the call to NewFoo or GetFoo, not the
call inside the generated function.  The Node.js and Python SDKs behave
this way for both operations.

A generated constructor reported the user's call correctly.  A generated
getter reported the ctx.ReadResource line inside the getter body, so
every read resource pointed into the provider SDK instead of the
program.  The read path now skips the same number of frames as the
register path.

A new integration test generates a Go SDK from the test provider, runs a
program that calls the generated constructor and getter, and asserts the
recorded position of each resource.  Generating the SDK during the test
keeps the frames the SDK skips in step with the code that codegen
emits.

Fixes #24601
@iwahbe
iwahbe force-pushed the iwahbe/go-sdk-source-position branch from 63b290a to 5ffa54a Compare September 9, 2026 11:49
@iwahbe
iwahbe marked this pull request as draft September 9, 2026 11:49
auto-merge was automatically disabled September 9, 2026 11:49

Pull request was converted to draft

@iwahbe
iwahbe marked this pull request as ready for review September 9, 2026 12:04
@iwahbe
iwahbe enabled auto-merge September 9, 2026 12:12
@iwahbe
iwahbe added this pull request to the merge queue Sep 9, 2026
Merged via the queue into master with commit 2e1ed5c Sep 9, 2026
418 of 430 checks passed
@iwahbe
iwahbe deleted the iwahbe/go-sdk-source-position branch September 9, 2026 16:35
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.

Go SDK reports the wrong source position for read resources (inside the generated getter, not user code)

2 participants