{"record":{"id":"73381dd49e2340fa","repo":"discordjs/discord.js","slug":"cannot-properly-serialize-section-accessory-compon","errorCode":null,"errorMessage":"Cannot properly serialize section accessory component: ${component.type}","messagePattern":"Cannot properly serialize section accessory component: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/builders/src/components/Components.ts","lineNumber":274,"sourceCode":"\t\tcase ButtonStyle.Link:\n\t\t\treturn new LinkButtonBuilder(data);\n\t\tcase ButtonStyle.Premium:\n\t\t\treturn new PremiumButtonBuilder(data);\n\t\tdefault:\n\t\t\t// @ts-expect-error This case can still occur if we get a newer unsupported button style\n\t\t\tthrow new Error(`Cannot properly serialize button with style: ${data.style}`);\n\t}\n}\n\nexport function resolveAccessoryComponent(component: APISectionAccessoryComponent) {\n\tswitch (component.type) {\n\t\tcase ComponentType.Button:\n\t\t\treturn createButtonBuilder(component);\n\t\tcase ComponentType.Thumbnail:\n\t\t\treturn new ThumbnailBuilder(component);\n\t\tdefault:\n\t\t\t// @ts-expect-error This case can still occur if we get a newer unsupported component type\n\t\t\tthrow new Error(`Cannot properly serialize section accessory component: ${component.type}`);\n\t}\n}\n","sourceCodeStart":256,"sourceCodeEnd":277,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/builders/src/components/Components.ts#L256-L277","documentation":"resolveAccessoryComponent converts a section's accessory (the small component next to section text) into a builder. Only Button and Thumbnail accessories are supported; any other component type in the accessory slot hits the default branch and throws.","triggerScenarios":"Constructing or resolving a SectionBuilder with an accessory component whose `component.type` is neither ComponentType.Button nor ComponentType.Thumbnail — e.g. a raw API section payload with an unexpected accessory type from a newer API version.","commonSituations":"Forwarding/echoing raw API message data where sections carry newer accessory types; hand-assembled section JSON putting the wrong component in the accessory slot; outdated library after new accessory kinds were added.","solutions":["Update @discordjs/builders to the latest version in case new accessory types gained support.","Ensure the accessory passed to the section is a button or thumbnail; restructure data otherwise.","Guard resolution: check component.type against the supported set before calling resolveAccessoryComponent.","If data comes from raw API payloads, strip or transform unsupported accessories first."],"exampleFix":"// before\nnew SectionBuilder({ components: [...], accessory: mediaGalleryComponent }); // invalid accessory type\n// after\nnew SectionBuilder({ components: [...], accessory: new ThumbnailBuilder(...) });","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_ACCESSORIES = new Set([ComponentType.Button, ComponentType.Thumbnail]);\nif (!SUPPORTED_ACCESSORIES.has(component.type)) {\n  throw new Error(`Accessory must be a button or thumbnail, got ${component.type}`);\n}","typeGuard":"function isValidAccessory(c: { type: number }): c is APISectionAccessoryComponent {\n  return c.type === ComponentType.Button || c.type === ComponentType.Thumbnail;\n}","tryCatchPattern":"try {\n  const accessory = resolveAccessoryComponent(component);\n} catch (err) {\n  if ((err as Error).message.startsWith('Cannot properly serialize section accessory')) {\n    console.warn('Unsupported section accessory; only Button and Thumbnail are allowed.');\n  } else throw err;\n}","preventionTips":["Only place buttons or thumbnails in section accessory slots.","Validate raw API section payloads before constructing SectionBuilder.","Keep builders package current for newly supported accessory types."],"tags":["components","sections","unsupported-type"],"backgroundTag":"unsupported-component-type","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}