Skip to content

fix(go): make prompt.Desc() concurrency-safe#5486

Open
arthu-rguo wants to merge 1 commit into
genkit-ai:mainfrom
arthu-rguo:fix/prompt-desc-concurrent-safe
Open

fix(go): make prompt.Desc() concurrency-safe#5486
arthu-rguo wants to merge 1 commit into
genkit-ai:mainfrom
arthu-rguo:fix/prompt-desc-concurrent-safe

Conversation

@arthu-rguo

@arthu-rguo arthu-rguo commented Jun 7, 2026

Copy link
Copy Markdown

explanation:

  • ActionDef.Desc() is careful to avoid mutating the receiver when resolving schemas.
  • prompt.Desc() is not, as it mutates a deeply nested map without deep copying.
  • Calling prompt.Desc() concurrently will produce a fatal (unrecoverable) Go runtime panic.

fix:

  • Deep copy the nested map.

additional notes:

  • While developing my application, I was surprised by this because I had assumed Name() and Desc() were concurrency-safe simple getters.
  • I am guessing that this mutation was unintentional.
  • If it was in fact intentional for memoization, I'm happy to close this PR (or pivot to documenting the behaviour).

Checklist (if applicable):

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the 'Desc' method in 'go/ai/prompt.go' to clone the metadata maps ('desc.Metadata', 'prompt', 'input', and 'output') before modifying them, preventing in-place mutation of shared metadata structures. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants