Skip to content

Commit 9bf0ab9

Browse files
committed
fix(contracts): make AuthAccessStreamError wire-compatible across versions
The schema changed from { message } to { operation, cause } without backward compatibility, breaking schema decoding when client and server versions are mismatched during rolling deployments. Follow the same pattern as EnvironmentHttpInternalServerError: - Keep message: Schema.String in the schema (always on the wire) - Make operation optional for decode (old payloads only have message) - Remove cause from the schema (avoid exposing internal errors) - Use a custom constructor that requires operation and computes message
1 parent 7d654e4 commit 9bf0ab9

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

packages/contracts/src/auth.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,29 @@ export type AuthAccessStreamOperation = typeof AuthAccessStreamOperation.Type;
285285
export class AuthAccessStreamError extends Schema.TaggedErrorClass<AuthAccessStreamError>()(
286286
"AuthAccessStreamError",
287287
{
288-
operation: AuthAccessStreamOperation,
288+
operation: Schema.optional(AuthAccessStreamOperation),
289289
currentSessionId: Schema.optional(AuthSessionId),
290-
cause: Schema.Defect(),
290+
message: Schema.String,
291291
},
292292
) {
293-
override get message(): string {
293+
// @effect-diagnostics-next-line overriddenSchemaConstructor:off
294+
constructor(props: {
295+
readonly operation: AuthAccessStreamOperation;
296+
readonly currentSessionId?: string | undefined;
297+
readonly cause?: unknown;
298+
}) {
294299
const session =
295-
this.currentSessionId === undefined ? "" : ` for session ${this.currentSessionId}`;
296-
return `Authentication access stream operation ${this.operation} failed${session}.`;
300+
props.currentSessionId === undefined ? "" : ` for session ${props.currentSessionId}`;
301+
const message =
302+
"message" in props && typeof (props as any).message === "string"
303+
? (props as any).message
304+
: `Authentication access stream operation ${props.operation} failed${session}.`;
305+
super({
306+
operation: props.operation,
307+
...(props.currentSessionId === undefined ? {} : { currentSessionId: props.currentSessionId }),
308+
message,
309+
...(props.cause === undefined ? {} : { cause: props.cause }),
310+
} as any);
297311
}
298312
}
299313

0 commit comments

Comments
 (0)