Repository navigation
fix(import-mr): tolerate malformed frontmatter in AI learning output - #241
Merged
Merged
Conversation
The extract-mr command parsed the LLM's Markdown output as YAML via gray-matter. When the output contained a line starting with `*` (a markdown italic), js-yaml treated it as a YAML alias reference and threw an uncaught YAMLException, crashing the process with exit 1 and failing the CI pipeline. Extract the preprocessing and parse into a defensive `parseLearningDraft` helper that catches parse failures and falls back to empty frontmatter, so any AI output flows through instead of crashing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
8 tasks done
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…encent#241) The extract-mr command parsed the LLM's Markdown output as YAML via gray-matter. When the output contained a line starting with `*` (a markdown italic), js-yaml treated it as a YAML alias reference and threw an uncaught YAMLException, crashing the process with exit 1 and failing the CI pipeline. Extract the preprocessing and parse into a defensive `parseLearningDraft` helper that catches parse failures and falls back to empty frontmatter, so any AI output flows through instead of crashing. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The CI pipeline's
teamai ci extract-mrstep crashed with exit 1, failing the whole pipeline. Root cause:After the AI analysis completes, the LLM's Markdown output is parsed as YAML frontmatter via
gray-matter(src/import-mr.ts). When the output contains a line starting with*(a markdown italic, e.g.*说明:本次 MR 是 8 个 GitHub PR…*),js-yamlinterprets*fooas a YAML alias reference, has no matching anchor, and throws an uncaughtYAMLException:The
matter()call had notry/catch, so the exception propagated all the way up and killed the process.Fix
Extract the preprocessing + parse into a defensive
parseLearningDraft()helper that catches parse failures and falls back to empty frontmatter (title falls back to the MR title). Any AI output — however malformed as YAML — now flows through instead of crashing.Test Plan
npm run buildpassesnpx tsc --noEmitpassessrc/__tests__/import-mr.test.ts(4 cases incl. the exact CI-failing alias string) passessrc/__tests__/ci-extract-mr.test.tsstill passes (7/7)🤖 Generated with Claude Code