Commit Graph
3 Commits
Author SHA1 Message Date
Andy Low 69b620dd2f Harden MongoDB driver compatibility 2026-04-19 23:24:22 +01:00
Ben WestandCopilot 246e46adb3 fix: legacy UUID treatments findable via $or fallback (#6923)
updateIdQuery() and upsertQueryFor() now use
  {$or: [{identifier: UUID}, {_id: UUID}]}
instead of only {identifier: UUID}. This matches both:
- New documents (UUID in identifier field, ObjectId in _id)
- Legacy documents (UUID directly in _id, no identifier field)

Gated behind env.uuidHandling (UUID_HANDLING env var, default true).

All 30 treatment tests pass:
- 3 legacy UUID tests (issue-6923): DELETE, PUT, GET all work
- 12 gap-treat-012 tests: new data paths unaffected
- 15 uuid-handling tests: edge cases, UUID_HANDLING=false still works

Fixes #6923 (unable to edit/save/delete overrides for legacy data)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-25 15:20:51 -07:00
Ben WestandCopilot b8523430db test: add regression test proving #6923 legacy UUID data bug
Inserts a treatment directly into MongoDB with UUID as _id (no identifier
field) — the shape of overrides created before normalizeTreatmentId(). All 3
tests fail as expected:

- DELETE: responds 200 but deletedCount=0 (silent no-op)
- PUT: creates duplicate document instead of updating in place
- GET: returns 0 results (query rewrite misses legacy doc)

These tests document the legacy data gap and will pass once updateIdQuery()
is updated to use a $or fallback: {identifier: UUID} || {_id: UUID}.

Relates to: #6923, #8450

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-19 17:31:31 -07:00