Duplicate check
| Item |
Relation |
| #12 (open) |
Not duplicate — scoped source storage layout (line/category vs product dir) |
| No open issue |
Silent MD manifest sync failure on approve/upload |
Summary
After a successful PDF write and sources.yaml update, appendProductMdSource() updates the product MD sources: frontmatter list. If the MD file is missing or lacks valid --- frontmatter, the function returns without error. Callers (manualUpload, approve flow) still return { ok: true }, leaving sources.yaml and DB in sync but the canonical MD manifest stale.
Per CONTRIBUTING, the MD manifest is load-bearing for extraction — silent drift breaks downstream pipeline steps.
Steps to reproduce
-
Corrupt or delete a product's frontmatter block in {slug}.md (keep file, remove --- delimiters).
-
Upload a PDF:
curl -sS -X POST http://localhost:3210/api/pipeline/sources/upload \
-H 'Content-Type: application/json' \
--data '{ ... valid upload body ... }'
-
Response is success; sources.yaml has the new entry; product MD sources: list is unchanged — no error surfaced.
Silent early returns:
function appendProductMdSource(input: AppendMdSourceInput): void {
if (!fs.existsSync(input.mdPath)) {
return;
}
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
if (!fmMatch) return;
Expected behavior
Missing MD or malformed frontmatter surfaces an error to the caller (4xx/5xx or { ok: false, error: "..." }). Upload/approve should not report full success when MD manifest was not updated.
Actual behavior
Best-effort no-op; API returns success.
Suggested fix
- Change
appendProductMdSource to return Result<void> or throw on missing MD / bad frontmatter.
- Propagate error from
manualUpload and approve callers.
- Add unit test: corrupt frontmatter → caller gets error,
sources.yaml optionally rolled back.
PR scope
~30–50 lines + one test.
Duplicate check
Summary
After a successful PDF write and
sources.yamlupdate,appendProductMdSource()updates the product MDsources:frontmatter list. If the MD file is missing or lacks valid---frontmatter, the function returns without error. Callers (manualUpload, approve flow) still return{ ok: true }, leavingsources.yamland DB in sync but the canonical MD manifest stale.Per CONTRIBUTING, the MD manifest is load-bearing for extraction — silent drift breaks downstream pipeline steps.
Steps to reproduce
Corrupt or delete a product's frontmatter block in
{slug}.md(keep file, remove---delimiters).Upload a PDF:
Response is success;
sources.yamlhas the new entry; product MDsources:list is unchanged — no error surfaced.Silent early returns:
Expected behavior
Missing MD or malformed frontmatter surfaces an error to the caller (4xx/5xx or
{ ok: false, error: "..." }). Upload/approve should not report full success when MD manifest was not updated.Actual behavior
Best-effort no-op; API returns success.
Suggested fix
appendProductMdSourceto returnResult<void>or throw on missing MD / bad frontmatter.manualUploadand approve callers.sources.yamloptionally rolled back.PR scope
~30–50 lines + one test.