{"record":{"id":"0197693fe95d0a6a","repo":"SonarSource/sonarqube","slug":"unknown-type-s","errorCode":null,"errorMessage":"Unknown type '%s'","messagePattern":"Unknown type '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java","lineNumber":126,"sourceCode":"    }\n\n    response.noContent();\n  }\n\n  @CheckForNull\n  private String getHomepageParameter(DbSession dbSession, HomepageTypes.Type type, @Nullable String componentParameter, @Nullable String branchParameter) {\n    switch (type) {\n      case PROJECT:\n        checkArgument(isNotBlank(componentParameter), PARAMETER_REQUIRED, type.name(), PARAM_COMPONENT);\n        ProjectDto projectDto = componentFinder.getProjectByKey(dbSession, componentParameter);\n        return componentFinder.getBranchOrPullRequest(dbSession, projectDto, branchParameter, null).getUuid();\n      case PORTFOLIO, APPLICATION:\n        checkArgument(isNotBlank(componentParameter), PARAMETER_REQUIRED, type.name(), PARAM_COMPONENT);\n        return componentFinder.getByKey(dbSession, componentParameter).uuid();\n      case PORTFOLIOS, PROJECTS, ISSUES:\n        return null;\n      default:\n        throw new IllegalArgumentException(format(\"Unknown type '%s'\", type.name()));\n    }\n  }\n\n}\n","sourceCodeStart":108,"sourceCodeEnd":131,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetHomepageAction.java#L108-L131","documentation":"SetHomepageAction throws this IllegalArgumentException when the requested homepage 'type' parameter is a known enum value whose rendering still requires a component uuid that is absent, or falls through to an unhandled enum constant. It signals the server received a homepage type it cannot resolve to a configuration — either the type is genuinely unknown to this SonarQube version or a required companion parameter (component) was omitted/blank.","triggerScenarios":"POST api/users/set_homepage with type set to PORTFOLIO or APPLICATION but no/blank 'component' parameter, or a type value not present in the server's HomepageType enum.","commonSituations":"Newer client UI sends a homepage type unknown to an older/newer server after upgrade/downgrade mismatch; scripted API call omits component for portfolio/application homepages; hand-crafted type string casing mismatch.","solutions":["When type is PORTFOLIO or APPLICATION, always pass component=<key> of the portfolio/application.","Align client and server versions — the homepage type may only exist in a different SonarQube/LTS version; upgrade the server or pin the UI plugin.","Use a supported type (PROJECTS, PORTFOLIOS, ISSUES) which require no component parameter.","Check the exact spelling/casing of the type value against the server's supported enum via the web UI settings page."],"exampleFix":"// before: portfolio homepage without component\ncurl -u \"$TOKEN:\" -X POST 'https://sonar/api/users/set_homepage?type=PORTFOLIO'\n// after: include the component key\ncurl -u \"$TOKEN:\" -X POST 'https://sonar/api/users/set_homepage?type=PORTFOLIO&component=my-portfolio-key'","handlingStrategy":"validation","validationCode":"const needsComponent = ['PORTFOLIO','APPLICATION'].includes(type);\nif (needsComponent && !component) throw new Error(`homepage type ${type} requires a component parameter`);\nconst supported = ['PROJECTS','PORTFOLIOS','ISSUES','PORTFOLIO','APPLICATION'];\nif (!supported.includes(type)) throw new Error(`homepage type ${type} unknown on this server version`);","typeGuard":"function isKnownHomepageType(t) {\n  return ['PROJECTS','PORTFOLIOS','ISSUES','PORTFOLIO','APPLICATION'].includes(t);\n}","tryCatchPattern":"try {\n  await setHomepage(type, component);\n} catch (e) {\n  if (e.status === 400 && /Unknown type/.test(e.message)) {\n    await setHomepage('PROJECTS'); // fall back to a safe default homepage\n  } else throw e;\n}","preventionTips":["Pass component whenever type is PORTFOLIO or APPLICATION","Pin client/server versions so homepage types match","Use uppercase enum names exactly as defined","Prefer no-parameter types (PROJECTS, PORTFOLIOS, ISSUES) in scripts"],"tags":["sonarqube","rest-api","enum","bad-request"],"backgroundTag":"invalid-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}