Skip to content

Commit 24db8a1

Browse files
committed
test(metadata-protocol): read the backfill receipt's declared organization field apart from the carriers
Claude-Session: https://claude.ai/code/session_016GiHYRmLSNWTfbX9gVQkpz Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8987141 commit 24db8a1

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/types': patch
3+
---
4+
5+
fix(types): `operatorFacingErrorText` answers through the driver-fault redaction, so an operator-facing record carries no statement and no bound value
6+
7+
Clause-②: no
8+
9+
- **What changed.** `operatorFacingErrorText` passes every text it returns through `redactStatementFromMessage`, the one driver-fault redaction in this package. Text it reads off a raw-statement fault's `cause` is cut with `{ statementSent: true }`, which is the cut `@objectstack/driver-sql` applies to its own log line for the same fault. Every other text asks the shared leak predicate, as the engine's own log line does.
10+
- **What an operator reads now.** The records this helper fills, in `os db clean` and in the metadata migrations and probes, keep the dialect's own diagnostic: the missing column, the failed constraint or the locked database. The value slots the redaction's dialect templates own are cut from it, and the redaction's marker stands where the statement was removed. The records no longer carry the statement or the values bound into it.
11+
- **What does not change.** Text that is not a driver dump comes back exactly as before, empty text included. The thrown error is not touched: its `code`, `status`, class and `cause` reach every other reader as the driver composed them. The function's signature and the package's exports are unchanged.

‎packages/metadata-protocol/src/migrations/raw-exec-operator-detail-16657.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ describe('[#21418] a bound sentinel reaches no carrier at any site in this packa
515515
const err = rawStatementFault(
516516
knexDump(sql, [], `Duplicate entry '${SENTINEL}' for key 't.idx_real'`),
517517
);
518-
Object.assign((err as { cause: object }).cause, { code: 'ER_DUP_ENTRY', errno: 1062 });
518+
Object.assign((err as unknown as { cause: object }).cause, { code: 'ER_DUP_ENTRY', errno: 1062 });
519519
return err;
520520
};
521521
const options = {
@@ -548,6 +548,13 @@ describe('[#21418] a bound sentinel reaches no carrier at any site in this packa
548548
* with the organization the probe finds BEING the sentinel, so the
549549
* stamp and the counter merge bind it themselves, and every refusal
550550
* composed from the statement and parameters actually sent.
551+
*
552+
* ⚠️ The run's receipt names the organization it adopted, on purpose
553+
* and not through the helper: `organizationId` is a declared field of
554+
* the result (and of the `info` line a repair writes, which this
555+
* logger does not record). So the scan below reads the result WITHOUT
556+
* that one field, and pins the field's value separately, rather than
557+
* calling a declared receipt a leak.
551558
*/
552559
function sentinelExec(refuse: (sql: string) => boolean) {
553560
return async (sql: string, params?: unknown[]): Promise<unknown> => {
@@ -629,7 +636,9 @@ describe('[#21418] a bound sentinel reaches no carrier at any site in this packa
629636

630637
expect(fixture.seen.length, 'the site was never refused').toBeGreaterThan(0);
631638
expect(fixture.seen.every((m) => m.includes(SENTINEL))).toBe(true);
632-
expect(inspect(result, { depth: 8 })).not.toContain(SENTINEL);
639+
const { organizationId, ...carriers } = result as typeof result & { organizationId?: string };
640+
expect([undefined, SENTINEL]).toContain(organizationId);
641+
expect(inspect(carriers, { depth: 8 })).not.toContain(SENTINEL);
633642
expect(logged(log)).not.toContain(SENTINEL);
634643
if (line === '') {
635644
expect(result.status).toBe('absent');

0 commit comments

Comments
 (0)