[Go] Dotprompt snake case
Describe the bug
When passing a Go struct as prompt input to .prompt, fields tagged with snake_case (e.g., org_name, date_range) are silently missing in the rendered prompt. No error is thrown. Using camelCase works.
To Reproduce
- example.prompt
---
model: openai/gpt-4.1-mini
input:
schema:
items(array):
org_name: string
date_range: string
---
{{#each items as |it|}}
Org: {{ it.org_name }}
Range: {{ it.date_range }}
{{/each}}
- Go
prompt := genkit.LookupPrompt(Genkit, promptName)
if prompt == nil {
return nil, fmt.Errorf("prompt %s not found", promptName)
}
actionOpts, err := prompt.Render(ctx, input)
if err != nil {
return nil, fmt.Errorf("error rendering prompt: %w", err)
}
Log the action options and see that org and date range are missing from the parsed prompt.
- Control: Works if using camelCase (template + struct tags):
orgName,dateRange.
Expected behavior
Snake_case JSON keys should be available in the template per struct tags; the rendered prompt should include the values or report a validation error if mismatched.
Environment
- OS: macOS (darwin/arm64)
- Go: 1.25.1
- Genkit (Go): 0.7.x
Hey @jannwitt thanks for bringing this up. I'll take a closer look at this.
Hey @hugoaguirre FYI We encountered another issue with picoschema, where output variable with type enum lead to errors in marshaling the llm responses. We did not dig deeper, everything works well with json schema definitions so we are using those now.
Hi @jannwitt this issue is the next one in my priority list.
I'll keep you posted.
Thanks for the update!
Hello @jannwitt. I was investigating this issue and found out that the package we are depending on (to render handlebars template) does not support snake case at the moment.
Could it be possible if you change your handlebars template to use camel case in the meantime?
{{#each items as |it|}}
Org: {{ it.orgName }}
Range: {{ it.dateRange }}
{{/each}}
Thanks @hugoaguirre! Sure thing, we actually just went for JSON Schema definitions instead of Picoschema.
Maybe a little update in the docs could help others to avoid this issue. Silent failure in prompt rendering can bring you into trouble!
Hi @jannwitt, after revisiting the code, I found out my initial analysis was wrong. The fix should be available in the next release.