Skip to content

generator: Fix frontmatter stripping, truncation, and client close - #269

Open
jwren wants to merge 1 commit into
flutter:mainfrom
jwren:gemini-4-follow-up-2
Open

jwren wants to merge 1 commit into
flutter:mainfrom
jwren:gemini-4-follow-up-2

Conversation

@jwren

@jwren jwren commented Nov 19, 2026

Copy link
Copy Markdown
Member

Naive indexOf('---') stripping in GeminiService.cleanContent truncated Markdown horizontal rules, while MAX_TOKENS or frontmatter-only responses bypassed retry checks and overwrote SKILL.md with incomplete or body-less output.

Parse leading YAML frontmatter via package:yaml (including camelCase keys and block scalars), strip 3+/4-backtick outer code fences, reject non-STOP finishReason and empty cleaned bodies inside retry loops, and add close() to release internally owned HTTP clients.

Refs: #267 (Gemini 4 generator follow-up, part 2 of 3)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (125 passed)

Naive indexOf('---') stripping truncated Markdown horizontal rules,
while MAX_TOKENS or frontmatter-only responses bypassed retry checks
and overwrote SKILL.md with incomplete or body-less output.

Parse leading YAML frontmatter via package:yaml (including camelCase
keys and block scalars), strip 3+/4-backtick outer fences, reject
non-STOP finishReason and empty cleaned bodies inside retry loops,
and add close() to release internally owned HTTP clients.

Refs: flutter#267 (Gemini 4 generator follow-up)
Tested: dart format, dart analyze --fatal-infos --fatal-warnings, dart test (125 passed)

@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 improves the Gemini service by adding robust HTTP client lifecycle management, refining the content cleaning logic to better handle YAML frontmatter and markdown fences, and enhancing response validation. I have reviewed the changes and provided feedback on improving null safety in the response extraction logic and ensuring broader exception handling during YAML parsing.

@jwren
jwren requested a review from johnpryan November 19, 2026 02:30
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