paperclipai/paperclip · error
Invalid Teams file consent binding
Error message
Invalid Teams file consent binding
What it means
createTeamsFileConsentBinding merges the input with a fixed schema marker and a freshly generated pcfc_ token, then validates the whole object against bindingSchema (zod). If validation fails — e.g. missing/invalid thread or user fields — it throws this opaque error. The parsed result is frozen as an immutable binding.
Source
Thrown at server/src/services/chat-teams-file-consent.ts:74
.int()
.positive()
.max(Math.min(MAX_ATTACHMENT_BYTES, 60 * 1024 * 1024 - 1)),
filename,
token: tokenSchema,
expiresAt: z.iso.datetime(),
})
.strict();
export type TeamsFileConsentBinding = Readonly<z.infer<typeof bindingSchema>>;
export function createTeamsFileConsentBinding(
input: Omit<TeamsFileConsentBinding, "schema" | "token">,
): TeamsFileConsentBinding {
const parsed = bindingSchema.safeParse({
...input,
schema: SCHEMA,
token: `pcfc_${randomBytes(32).toString("base64url")}`,
});
if (!parsed.success) throw new Error("Invalid Teams file consent binding");
return Object.freeze(parsed.data);
}
export function parseTeamsFileConsentBinding(
input: unknown,
): TeamsFileConsentBinding | null {
const parsed = bindingSchema.safeParse(input);
return parsed.success ? Object.freeze(parsed.data) : null;
}
function digest(value: unknown): string {
return createHash("sha256").update(JSON.stringify(value)).digest("hex");
}
const privateContextSchema = z
.object({
companyId: z.uuid(),
endpointId: z.uuid(),View on GitHub (pinned to 01ad858492)
Solutions
- Log/reproduce the safeParse failure: temporarily validate the same input with the exported bindingSchema (or call parseTeamsFileConsentBinding) to see field-level issues
- Ensure all required fields (thread id, user id, etc.) are present with correct types before the call
- Align the caller with the current schema version after upgrades
Example fix
// before
const binding = createTeamsFileConsentBinding(input); // opaque throw
// after
const probe = parseTeamsFileConsentBinding({ ...input, schema: 'teams.file-consent/v1' });
if (!probe) throw new Error(`invalid consent input: ${JSON.stringify(input)}`);
const binding = createTeamsFileConsentBinding(input); Defensive patterns
Strategy: validation
Validate before calling
const probe = parseTeamsFileConsentBinding(input); if (!probe) throw new Error('consent binding input failed schema before create'); Type guard
function isConsentBindingInput(v: unknown): v is ConsentBindingInput { const x = v as ConsentBindingInput; return typeof x.threadId === 'string' && x.threadId.length > 0 && typeof x.userId === 'string' && x.userId.length > 0; } Try / catch
try { const binding = createTeamsFileConsentBinding(input); } catch (err) { if ((err as Error).message === 'Invalid Teams file consent binding') { console.error('rejected consent input', input); return null; } throw err; } Prevention
- Pre-validate with parseTeamsFileConsentBinding or the zod schema to get field-level errors
- Keep callers updated with schema-required fields across versions
- Validate Teams webhook payloads at the boundary before building bindings
When it happens
Trigger: Calling createTeamsFileConsentBinding with input missing required fields, wrong types (e.g. threadId as number), extra/unexpected shapes, or anything failing the bindingSchema.safeParse after schema/token injection.
Common situations: Building the binding from a parsed Teams webhook payload that lacks expected fields; version drift where the schema added a required field the caller doesn't supply; malformed consent card data forwarded from a bot handler.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Invalid Teams private binding
- Invalid Teams upload state
- Configuration does not match the plugin's instanceConfigSche
- createServerAdapter() from "${packageName}" returned an inva
- Invalid worktree seed manifest at ${manifestPath}.
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10).
Data as JSON: /api/errors/e4574bbe795aa50c.
Report an issue: GitHub.