Skip to content

Return 400 for chat template build errors#1356

Merged
shihaobai merged 1 commit into
mainfrom
openai_br
Jun 15, 2026
Merged

Return 400 for chat template build errors#1356
shihaobai merged 1 commit into
mainfrom
openai_br

Conversation

@shihaobai

Copy link
Copy Markdown
Collaborator

No description provided.

@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 refactors the exception handling in build_prompt.py when applying a chat template, catching Exception instead of BaseException and raising a ValueError. The reviewer recommends preserving the exception chain by removing from None when raising the ValueError to ensure that the original traceback (such as Jinja2 rendering errors) is not lost, which is important for server-side debugging.

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.

Comment on lines +162 to +163
except Exception as e:
raise ValueError(f"Failed to build prompt: {e}") from None

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.

medium

Suppressing the exception context with from None makes it difficult to debug chat template rendering issues on the server side, as the original traceback (e.g., from Jinja2) is lost. Consider preserving the exception chain by raising the ValueError without from None so that the underlying cause is visible in server logs.

Suggested change
except Exception as e:
raise ValueError(f"Failed to build prompt: {e}") from None
except Exception as e:
raise ValueError(f"Failed to build prompt: {e}")

@shihaobai shihaobai merged commit 630f7b8 into main Jun 15, 2026
1 check passed
@shihaobai shihaobai deleted the openai_br branch June 15, 2026 14:43
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.

1 participant