{"record":{"id":"191ccbaf9ca54310","repo":"DIYgod/RSSHub","slug":"unhandled-attribute-attribute","errorCode":null,"errorMessage":"Unhandled attribute: ${attribute}","messagePattern":"Unhandled attribute: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/bbc/utils.tsx","lineNumber":65,"sourceCode":"    blocks?: Block[];\n    items?: Block[];\n};\n\nconst applyAttributes = (content: JSX.Element | string, attributes?: BlockAttribute[]): JSX.Element | string => {\n    let result: JSX.Element | string = content;\n    const attributeList = attributes ?? [];\n    for (const attribute of attributeList) {\n        switch (attribute) {\n            case 'bold':\n                result = <strong>{result}</strong>;\n                break;\n\n            case 'italic':\n                result = <em>{result}</em>;\n                break;\n\n            default:\n                throw new Error(`Unhandled attribute: ${attribute}`);\n        }\n    }\n    return result;\n};\n\nconst extractText = (blocks?: Block[]): string => {\n    if (!blocks?.length) {\n        return '';\n    }\n\n    return blocks\n        .map((block) => {\n            if (block.type === 'fragment') {\n                return block.model?.text ?? '';\n            }\n\n            if (block.model?.text) {\n                return block.model.text;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bbc/utils.tsx#L47-L83","documentation":"bbc/utils.tsx wraps text in <strong>/<em> based on an attribute list. Any attribute other than 'bold' or 'italic' falls through to default and throws, so a new BBC visual attribute (e.g. underline, strikethrough) surfaces immediately instead of being silently dropped.","triggerScenarios":"The BBC content API returns an attribute string that is not 'bold' or 'italic' inside a block's attributes array - BBC added a new inline formatting attribute.","commonSituations":"BBC rolls out underline/strikethrough/link styling on a new article; an old article migrated with a legacy attribute value; a regional BBC endpoint returning an extended attribute set.","solutions":["Inspect the failing block in the BBC API response to see the new attribute string.","Add a case for the new attribute (e.g. 'underline' -> <u>, 'strikethrough' -> <s>) in the switch at lib/routes/bbc/utils.tsx:54.","If unsure how to render it, add a case returning the unmodified result instead of throwing."],"exampleFix":"// before\ncase 'italic': result = <em>{result}</em>; break;\ndefault: throw new Error(`Unhandled attribute: ${attribute}`);\n// after\ncase 'italic': result = <em>{result}</em>; break;\ncase 'underline': result = <u>{result}</u>; break;\ndefault: return result;","handlingStrategy":"fallback","validationCode":"const KNOWN_ATTRIBUTES = new Set(['bold', 'italic']);\nfunction allAttributesKnown(attrs: string[] = []): boolean {\n  return attrs.every((a) => KNOWN_ATTRIBUTES.has(a));\n}","typeGuard":"const isKnownAttribute = (a: unknown): boolean =>\n  a === 'bold' || a === 'italic';","tryCatchPattern":"try {\n  return wrapWithAttributes(result, attributes);\n} catch (e) {\n  if (e instanceof Error && /Unhandled attribute/.test(e.message)) {\n    logger.warn(e.message);\n    return result; // ignore unknown attribute, keep text\n  }\n  throw e;\n}","preventionTips":["Make the default case return result unchanged rather than throw for inline attributes.","Pin a BBC API response fixture so new attributes are caught by CI.","Log unknown attributes so the route can be extended promptly."],"tags":["bbc","parsing","api-change","rss-route"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}