Repository navigation
fix(import): validate AI learning draft metadata - #1305
Conversation
Signed-off-by: ydflow <[email protected]>
|
No findings in the specified diff. The title fallback and tags filtering address the reported crashes without rewriting draft content. Regression tests cover malformed metadata and queued filenames; both knowledge guides are updated. The PR description documents sufficient testing, including a representative built-CLI E2E run that saved both drafts unchanged. Additional provider/agent coverage is explicitly deferred to CI. Review was read-only; I did not run, build, or install PR code. |
There was a problem hiding this comment.
This was generated by AI during triage.
@ydflow Thanks, this looks good. Approving.
We checked it with the built CLI on this head and on its base 97f1e7b4. A local GitLab stand-in served two MRs, and a stand-in claude returned the drafts:
| draft | base | this PR |
|---|---|---|
tags: agent (--output) |
exit 1, tags.join is not a function, one draft written |
exit 0, 2 succeeded, both drafts byte-equal to the input |
title: 42 (queue) |
exit 1, toLowerCase is not a function, one draft queued |
exit 0, both queued, the second under the MR title |
tsc, lint, the 57 unit tests and the new e2e pass on this head. On the base, 6 of the 9 new unit cases fail, and so does the new e2e. That matches the body.
Optional, not blocking:
[P3 nit]teamai ci extract-mrgoes through the same function, but no test drives it with a non-string title.[P3 nit]Theknowledge.mdparagraph describes a bugfix's internals more than behavior a user sets up, so it could be dropped under the "change docs rarely" rule. Fine to keep.
Signed-off-by: ydflow <[email protected]> Co-authored-by: ydflow <[email protected]>
Summary
An MR learning can be valid YAML but still have the wrong metadata types:
tags: agentcrashes attags.join, andtitle: 42crashes attoLowerCasewhen the draft is queued. The AI call has already completed, but the learning is not saved.Check the types before using these fields: use the MR title when the generated title is not a string, and display only string entries from a tags array. Keep the draft content as received by the importer. Update the English and Chinese knowledge guides.
Type of Change
Test Plan
npm run buildnpx tsc --noEmitnpm run lintnpx vitest run src/__tests__/import-mr.test.ts src/__tests__/import-mr-threads.test.ts src/__tests__/import-mr-learnings-checkout.test.ts src/__tests__/ci-extract-mr.test.ts src/__tests__/contribute.test.ts --maxWorkers=3— 57 tests passed.npx vitest run --config vitest.windows.config.ts --maxWorkers=3— 665 tests passed in 23 files.npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/import-mr-draft-metadata.test.ts --maxWorkers=1 --retry=0— the built CLI imported two MRs, one with scalar tags and one with normal tags; exit 0,2 succeeded, 0 failed, and both saved drafts matched the fixture contents.git diff --checkBefore the fix, six of the nine added metadata regression cases failed, including the
tags.joinand queued-titletoLowerCaseerrors. The tests cover output files, queued filenames, mixed tags and valid metadata.Related Issues
Follow-up to #241: that change catches YAML parsing errors; these inputs parse successfully and fail when their field types are trusted.
Notes for Reviewers
Local validation ran on Windows with Node 24. The full POSIX unit suite and other provider/agent combinations are left to CI. The real-CLI E2E uses a local HTTP GitLab fixture and a deterministic AI subprocess; no live model or remote GitLab instance was used.