{"record":{"id":"b46b0a0912d19e5c","repo":"flarum/framework","slug":"args","errorCode":null,"errorMessage":"...args","messagePattern":"\\.\\.\\.args","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"framework/core/js/src/common/helpers/fireDebugWarning.ts","lineNumber":17,"sourceCode":"import app from '../app';\n\n/**\n * Calls `console.warn` with the provided arguments, but only if the forum is in debug mode.\n *\n * This function is intended to provide warnings to extension developers about issues with\n * their extensions that may not be easily noticed when testing, such as accessibility\n * issues.\n *\n * These warnings should be hidden on production forums to ensure webmasters are not\n * inundated with do-gooders telling them they have an issue when it isn't something they\n * can fix.\n */\nexport default function fireDebugWarning(...args: Parameters<typeof console.warn>): void {\n  if (!app.data.resources.find((r) => r.type === 'forums')?.attributes?.debug) return;\n\n  console.warn(...args);\n}\n\n/**\n * Fire a Flarum deprecation warning which is shown in the JS console.\n *\n * These warnings are only shown when the forum is in debug mode, and the function exists to\n * reduce bundle size caused by multiple warnings across our JavaScript.\n *\n * @param message The message to display. (Short, but sweet, please!)\n * @param githubId The PR or Issue ID with more info in relation to this change.\n * @param [removedFrom] The version in which this feature will be completely removed. (default: 2.0)\n * @param [repo] The repo which the issue or PR is located in. (default: flarum/core)\n *\n * @see {@link fireDebugWarning}\n */\nexport function fireDeprecationWarning(message: string, githubId: string, removedFrom: string = '2.0', repo: string = 'flarum/core'): void {\n  // GitHub auto-redirects between `/pull` and `/issues` for us, so using `/pull` saves 2 bytes!\n  fireDebugWarning(`[Flarum ${removedFrom} Deprecation] ${message}\\n\\nSee: https://github.com/${repo}/pull/${githubId}`);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/js/src/common/helpers/fireDebugWarning.ts#L1-L35","documentation":"fireDebugWarning is a gate around console.warn: it looks up the 'forums' resource attributes and returns early unless debug is enabled, so warnings only reach the console in debug-mode forums. It is used by deprecation helpers and translations, letting library code emit diagnostics that stay silent for end users.","triggerScenarios":"Any call to fireDebugWarning(...) (directly or via fireDeprecationWarning, trans, preprocessTranslation, oncreate hooks) when app.data has no 'forums' resource or its attributes.debug is falsy — in which case the warning is silently dropped; otherwise console.warn(...args) fires.","commonSituations":"Users seeing flarum deprecation/translation warnings in their console after enabling debug mode on production-like data; extension authors confused why their warning doesn't appear because debug is off; missing forums resource in custom bootstraps.","solutions":["If you're the developer seeing the warning, fix the deprecated usage the message points to.","If warnings must be visible, enable debug mode in the forum admin/settings so attributes.debug is true.","If warnings shouldn't appear, turn debug off — this wrapper intentionally suppresses them.","Ensure the 'forums' resource is present in app.data when bootstrapping custom frontends.","Use fireDebugWarning instead of raw console.warn in extension code to respect debug gating."],"exampleFix":"// before\nconsole.warn('Using legacy API');\n// after\nimport fireDebugWarning from 'flarum/common/helpers/fireDebugWarning';\nfireDebugWarning('Using legacy API');","handlingStrategy":"validation","validationCode":"const forums = app.data.resources.find((r) => r.type === 'forums');\nconst debugOn = Boolean(forums?.attributes?.debug);\nif (debugOn) {\n  fireDebugWarning('my diagnostic message');\n}","typeGuard":"function isDebugMode(app) {\n  return Boolean(app?.data?.resources?.find((r) => r.type === 'forums')?.attributes?.debug);\n}","tryCatchPattern":"if (isDebugMode(app)) {\n  try { fireDebugWarning(msg); } catch (e) { /* never let diagnostics break the app */ }\n}","preventionTips":["Never rely on fireDebugWarning for user-facing messages — it is silent outside debug mode.","Check the forums resource exists in app.data before custom bootstraps.","Use fireDeprecationWarning for deprecations instead of console.warn.","Keep debug mode off in production to avoid console noise for users.","Audit extensions for deprecated usage whenever debug warnings appear."],"tags":["debug-mode","console-warning","frontend","flarum"],"backgroundTag":"debug-mode-warning","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}