{"record":{"id":"e4882f237c7730c2","repo":"angular/angular","slug":"jsonp-wrong-method","errorCode":"JSONP_WRONG_METHOD","errorMessage":"JSONP requests must use JSONP request method.","messagePattern":"JSONP requests must use JSONP request method\\.","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/common/http/src/jsonp.ts","lineNumber":134,"sourceCode":"\n  /**\n   * Get the name of the next callback method, by incrementing the global `nextRequestId`.\n   */\n  private nextCallback(): string {\n    return `ng_jsonp_callback_${nextRequestId++}`;\n  }\n\n  /**\n   * Processes a JSONP request and returns an event stream of the results.\n   * @param req The request object.\n   * @returns An observable of the response events.\n   *\n   */\n  handle(req: HttpRequest<never>): Observable<HttpEvent<any>> {\n    // Firstly, check both the method and response type. If either doesn't match\n    // then the request was improperly routed here and cannot be handled.\n    if (req.method !== 'JSONP') {\n      throw new RuntimeError(\n        RuntimeErrorCode.JSONP_WRONG_METHOD,\n        ngDevMode && JSONP_ERR_WRONG_METHOD,\n      );\n    } else if (req.responseType !== 'json') {\n      throw new RuntimeError(\n        RuntimeErrorCode.JSONP_WRONG_RESPONSE_TYPE,\n        ngDevMode && JSONP_ERR_WRONG_RESPONSE_TYPE,\n      );\n    }\n\n    // Check the request headers. JSONP doesn't support headers and\n    // cannot set any that were supplied.\n    if (req.headers.keys().length > 0) {\n      throw new RuntimeError(\n        RuntimeErrorCode.JSONP_HEADERS_NOT_SUPPORTED,\n        ngDevMode && JSONP_ERR_HEADERS_NOT_SUPPORTED,\n      );\n    }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/common/http/src/jsonp.ts#L116-L152","documentation":"The translation loader tries each registered parser's analyze() pass; if none can handle the file (unsupported format, wrong content for the extension, empty or corrupt file), it throws this error and appends each parser's analysis diagnostics explaining why every format rejected it.","triggerScenarios":"Pointing the localization build at an unsupported file: a .txt/.csv 'translation file', a JSON file not in the Angular translations shape, a 0-byte or truncated XLIFF, or content whose extension does not match its actual format.","commonSituations":"Wrong path or glob in the angular.json locales config; downloading translations from a TMS in the wrong format; saving a file with the wrong extension; empty files from failed exports.","solutions":["Read the appended per-parser messages to see why each format (XLIFF 1.2, XLIFF 2.0, XTB, JSON, ARB) rejected the file","Convert the file to a supported format and make the extension match the content","Verify the configured path actually points at your translation files and that they are non-empty and well-formed"],"exampleFix":"// before (angular.json)\n\"locales\": { \"fr\": \"src/locale/messages.fr.csv\" }\n\n// after\n\"locales\": { \"fr\": \"src/locale/messages.fr.xlf\" }","handlingStrategy":"validation","validationCode":"const SUPPORTED_EXTENSIONS = ['.xlf', '.xlf2', '.xtb', '.json', '.arb'];\nfunction looksLoadable(path: string, contents: string): boolean {\n  const ext = path.slice(path.lastIndexOf('.'));\n  if (!SUPPORTED_EXTENSIONS.includes(ext)) return false;\n  if (contents.trim().length === 0) return false;\n  if (ext === '.json' || ext === '.arb') {\n    try { JSON.parse(contents); return true; } catch { return false; }\n  }\n  return contents.trimStart().startsWith('<?xml') || contents.includes('<');\n}","typeGuard":"function isSupportedTranslationFile(path: string): boolean {\n  return ['.xlf', '.xlf2', '.xtb', '.json', '.arb'].some((ext) => path.endsWith(ext));\n}","tryCatchPattern":"try {\n  const bundles = loader.loadBundles(filePaths, locales);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('no \"TranslationParser\"')) {\n    // check the appended per-parser reasons; convert the file or fix the path/extension\n  } else throw e;\n}","preventionTips":["Use only supported translation formats (.xlf, .xlf2, .xtb, .json, .arb) with matching extensions","Double-check locales paths/globs in angular.json after moving or renaming files","Verify downloaded/exported translations are non-empty and in the expected format before committing"],"tags":["angular","localize","i18n","file-format","translation-files"],"backgroundTag":"unsupported-translation-format","analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}