In apps/apollo/src/lib/org/inviteCode/dbUtils/index.ts, DB_INVITE_CODE.get was casting Prisma JsonValue metadata directly to SingleInviteCode['metadata'] with no runtime validation. Legacy or malformed rows could silently propagate bad data downstream.
Fix: import DBInviteCodeMetadataSchema as a runtime value and replace the unsafe as cast with safeParse; return Err(OrgInviteCodeError.InternalServerError) when the parse fails.
In apps/apollo/src/lib/org/inviteCode/joinOrgWInviteCode.ts, the switch (metadata.type) at the dispatch call site had no default: branch, so any unrecognised variant would fall through and return undefined (silently violating the Result<void, JoinError> contract).
Fix: add an exhaustive default: branch with a never guard that returns a typed Err.
check-types; node_modules is not installed in this worktree so local typecheck/tests cannot be run.DBInviteCodeMetadataSchema is a value export from @composio/db (re-exported from packages/db/src/schema/inviteCode.ts); the previous import type keyword was dropped so the runtime value is now available.never exhaustiveness pattern in the default branch is valid because metadata is typed as the full discriminated union and all three variants are handled above; the as { type: string } cast is only used for the runtime error message string.SingleInviteCode from get() when metadata was malformed will now receive an Err; ensure all callers handle Error_500 in the return type (they all use Result propagation so this is safe).🤖 Generated with Claude Code