Skip to content

fix(go): fixed bad dotprompt output format parsing#4109

Merged
apascal07 merged 1 commit intomainfrom
ap/go-json-fix
Jan 12, 2026
Merged

fix(go): fixed bad dotprompt output format parsing#4109
apascal07 merged 1 commit intomainfrom
ap/go-json-fix

Conversation

@apascal07
Copy link
Collaborator

Fixes #4097.

Checklist (if applicable):

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @apascal07, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the handling of prompt definitions by improving how input and output JSON schemas are parsed and applied, addressing a previous limitation with dotprompt output format parsing. It also enhances the general utility for extracting JSON content embedded within markdown, making it more adaptable to different markdown formatting styles. These changes collectively lead to more reliable and flexible prompt processing and JSON data extraction.

Highlights

  • Enhanced Prompt Schema Parsing: The LoadPromptFromSource function in go/ai/prompt.go has been updated to correctly parse both input and output schemas. It now distinguishes between schema references ($ref) and inline schema definitions, ensuring that the appropriate schema type is applied. For output schemas, if an inline schema is provided without an explicit format, it will default to OutputFormatJSON.
  • Improved JSON Extraction from Markdown: The ExtractJSONFromMarkdown utility in go/internal/base/json.go has been made more robust. It now supports case-insensitive matching for json fenced code blocks (e.g., JSON, Json) and includes a fallback mechanism to extract JSON from plain fenced code blocks (```) if no json specific block is found. This makes the extraction process more flexible.
  • Expanded Test Coverage: New test cases have been added in go/ai/prompt_test.go to validate the correct parsing of inline output schemas. Additionally, go/internal/base/json_test.go now includes comprehensive tests for the updated ExtractJSONFromMarkdown function, covering various scenarios like different casing for json identifiers, plain code blocks, and preference for json blocks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 addresses an issue with dotprompt output format parsing by refining the logic for loading input and output schemas. The changes correctly handle $ref references within schemas and ensure that the output format defaults to JSON when a schema is provided. Additionally, the ExtractJSONFromMarkdown utility has been made more robust by supporting case-insensitive 'json' identifiers and gracefully falling back to plain code blocks. Comprehensive test cases have been added to validate these enhancements, ensuring the reliability and correctness of the parsing logic.

@apascal07 apascal07 merged commit 8774e81 into main Jan 12, 2026
6 checks passed
@apascal07 apascal07 deleted the ap/go-json-fix branch January 12, 2026 18:03
@yesudeep yesudeep mentioned this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Go] Prompt Execute Output() fails to parse JSON wrapped in markdown code blocks (regression in v1.3.0)

2 participants