{"record":{"id":"2d7d2f3eb2e6dd9b","repo":"medusajs/medusa","slug":"warning-could-not-parse-candidate-using-defau","errorCode":null,"errorMessage":"Warning: could not parse ${candidate}, using default config","messagePattern":"Warning: could not parse (.+?), using default config","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/http-types-generator/src/config/index.ts","lineNumber":66,"sourceCode":"  private static _instance: ResolvedHttpTypesConfig | null = null\n\n  /**\n   * Walks up the directory tree from `startDir` to find the nearest ancestor\n   * (inclusive) that contains `http-types.config.json`. Returns the directory\n   * path and parsed contents, or `undefined` if the file is not found.\n   */\n  private static findConfigFile(\n    startDir: string\n  ): { dir: string; config: Partial<HttpTypesConfig> } | undefined {\n    let dir = startDir\n    while (true) {\n      const candidate = path.join(dir, Config.CONFIG_FILE_NAME)\n      if (existsSync(candidate)) {\n        try {\n          const raw = readFileSync(candidate, \"utf-8\")\n          return { dir, config: JSON.parse(raw) as Partial<HttpTypesConfig> }\n        } catch {\n          console.warn(\n            `Warning: could not parse ${candidate}, using default config`\n          )\n          return { dir, config: {} }\n        }\n      }\n      const parent = path.dirname(dir)\n      if (parent === dir) break\n      dir = parent\n    }\n    return undefined\n  }\n\n  /**\n   * Builds a resolved config by deep-merging `override` over DEFAULTS.\n   * When `override` is provided the config file is not read and `projectRoot`\n   * is set to `process.cwd()`. When omitted, the nearest `http-types.config.json`\n   * is found by searching upward from `process.cwd()`; its directory becomes\n   * `projectRoot`. Falls back to `process.cwd()` when no config file is found.","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/cli/http-types-generator/src/config/index.ts#L48-L84","documentation":"The http-types-generator CLI looks for its config file (http-types.config.json by default) walking up directories. If it finds the file but JSON.parse fails (malformed JSON), it warns and continues with the default/empty config, so custom settings like routes dirs or excludes are silently ignored.","triggerScenarios":"A http-types config file with a syntax error: trailing comma, single quotes, unquoted keys, or a BOM/comment.","commonSituations":"Hand-edited JSON with a trailing comma; file generated by a tool that emits JSON5; merge conflict leftovers.","solutions":["Validate the file with a JSON linter or `npx jsonlint http-types.config.json` and fix syntax errors","Remove trailing commas and comments; use double quotes","Re-run the generator and confirm the warning disappears"],"exampleFix":"// before (http-types.config.json)\n{ 'srcDir': 'src', }\n\n// after\n{ \"srcDir\": \"src\" }","handlingStrategy":"validation","validationCode":"import { readFileSync } from \"fs\"\nconst raw = readFileSync(\"http-types.config.json\", \"utf8\")\nJSON.parse(raw) // throws synchronously if malformed — fix before running generator","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint JSON config files in CI (jsonlint / prettier check)","Avoid comments and trailing commas in JSON configs"],"tags":["cli","http-types-generator","json","config"],"backgroundTag":"config-parse-failure","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}