Skip to content

Commit ccfda8e

Browse files
committed
Restore operation-specific messages in ServerAuthOperationError
The consolidation commit replaced individual error classes with ServerAuthOperationError, which introduced a generic message getter: 'Server authentication operation ${operation} failed.' Cloud HTTP handlers pass error.message into 500 response bodies via failEnvironmentCloudInternalError, so this caused user-facing messages to regress from specific strings like 'Could not verify the linked cloud account.' to the generic template. Restore the original per-operation messages through a lookup table keyed by the operation discriminant.
1 parent 87fac8a commit ccfda8e

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

apps/server/src/auth/EnvironmentAuth.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,28 @@ const ServerAuthInternalOperation = Schema.Literals([
9090
]);
9191
type ServerAuthInternalOperation = typeof ServerAuthInternalOperation.Type;
9292

93+
const serverAuthOperationMessages: Record<ServerAuthInternalOperation, string> = {
94+
validate_bootstrap_credential: "Failed to validate bootstrap credential.",
95+
validate_session_credential: "Failed to validate session credential.",
96+
issue_authenticated_session: "Failed to issue authenticated session.",
97+
issue_authenticated_access_token: "Failed to issue authenticated access token.",
98+
create_pairing_link: "Failed to create pairing link.",
99+
list_pairing_links: "Failed to list pairing links.",
100+
revoke_pairing_link: "Failed to revoke pairing link.",
101+
issue_session_token: "Failed to issue session token.",
102+
list_sessions: "Failed to list sessions.",
103+
revoke_session: "Failed to revoke session.",
104+
revoke_other_sessions: "Failed to revoke other sessions.",
105+
issue_websocket_token: "Failed to issue websocket token.",
106+
record_dpop_replay_state: "Failed to record DPoP proof replay state.",
107+
calculate_dpop_replay_key: "Failed to calculate DPoP replay key.",
108+
verify_linked_cloud_account: "Could not verify the linked cloud account.",
109+
read_linked_cloud_account: "Could not read the linked cloud account.",
110+
sign_cloud_link_jwt: "Failed to sign cloud link JWT.",
111+
sign_cloud_health_jwt: "Failed to sign cloud health JWT.",
112+
sign_cloud_mint_jwt: "Failed to sign cloud mint JWT.",
113+
};
114+
93115
export class ServerAuthOperationError extends Schema.TaggedErrorClass<ServerAuthOperationError>()(
94116
"ServerAuthOperationError",
95117
{
@@ -98,7 +120,7 @@ export class ServerAuthOperationError extends Schema.TaggedErrorClass<ServerAuth
98120
},
99121
) {
100122
override get message(): string {
101-
return `Server authentication operation '${this.operation}' failed.`;
123+
return serverAuthOperationMessages[this.operation];
102124
}
103125
}
104126

0 commit comments

Comments
 (0)