{"record":{"id":"72b085a2b27cb07a","repo":"SonarSource/sonarqube","slug":"quality-profile-not-found-uuid","errorCode":null,"errorMessage":"Quality profile not found: ${uuid}","messagePattern":"Quality profile not found: (.+?)","errorType":"exception","errorClass":"RowNotFoundException","httpStatus":404,"severity":"error","filePath":"server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java","lineNumber":62,"sourceCode":"public class QualityProfileDao implements Dao {\n\n  private final System2 system;\n  private final UuidFactory uuidFactory;\n\n  public QualityProfileDao(UuidFactory uuidFactory, System2 system) {\n    this.uuidFactory = uuidFactory;\n    this.system = system;\n  }\n\n  @CheckForNull\n  public QProfileDto selectByUuid(DbSession dbSession, String uuid) {\n    return mapper(dbSession).selectByUuid(uuid);\n  }\n\n  public QProfileDto selectOrFailByUuid(DbSession dbSession, String uuid) {\n    QProfileDto dto = selectByUuid(dbSession, uuid);\n    if (dto == null) {\n      throw new RowNotFoundException(\"Quality profile not found: \" + uuid);\n    }\n    return dto;\n  }\n\n  public List<QProfileDto> selectByUuids(DbSession dbSession, List<String> uuids) {\n    return executeLargeInputs(uuids, mapper(dbSession)::selectByUuids);\n  }\n\n  public List<QProfileDto> selectAll(DbSession dbSession) {\n    return mapper(dbSession).selectAll();\n  }\n\n  public List<RulesProfileDto> selectBuiltInRuleProfiles(DbSession dbSession) {\n    return mapper(dbSession).selectBuiltInRuleProfiles();\n  }\n\n  public List<RulesProfileDto> selectBuiltInRuleProfilesWithActiveRules(DbSession dbSession) {\n    return mapper(dbSession).selectBuiltInRuleProfilesWithActiveRules();","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java#L44-L80","documentation":"QualityProfileDao.selectOrFailByUuid is a strict-lookup variant of selectByUuid: it fetches a quality profile row by its UUID and throws RowNotFoundException when no row matches. This converts a silent null into an explicit 'profile does not exist' failure so callers never have to null-check.","triggerScenarios":"Calling selectOrFailByUuid(dbSession, uuid) with a UUID that does not exist in the QUALITY_PROFILES table (deleted profile, wrong UUID, profile from another instance).","commonSituations":"Restoring rules/profiles from a backup where the UUID no longer matches; referencing a profile UUID hardcoded in scripts or CI config after the profile was recreated (recreation generates a new UUID); cross-instance copies of profiles without their keys.","solutions":["Verify the UUID exists: query the QUALITY_PROFILES table (SELECT uuid, kee, name FROM quality_profiles) or use the Web API /api/qualityprofiles/search and correct the UUID.","Use the profile key (kee) or name/language instead of a stored UUID to look the profile up, since UUIDs change when a profile is recreated.","If the profile was deleted unintentionally, recreate it or restore it from the instance that owns it, then retry with the new UUID.","If a missing profile is an acceptable case, call selectByUuid instead of selectOrFailByUuid and handle null."],"exampleFix":"// before\nQProfileDto profile = qualityProfileDao.selectOrFailByUuid(dbSession, storedUuid);\n// after\nQProfileDto profile = qualityProfileDao.selectByUuid(dbSession, storedUuid);\nif (profile == null) {\n  profile = qualityProfileDao.selectByKey(dbSession, profileKey)\n      .orElseThrow(() -> new IllegalStateException(\"Profile not found for key \" + profileKey));\n}","handlingStrategy":"try-catch","validationCode":"QProfileDto existing = qualityProfileDao.selectByUuid(dbSession, uuid);\nif (existing == null) {\n  throw new IllegalStateException(\"Profile \" + uuid + \" not found; fetch key via /api/qualityprofiles/search\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  QProfileDto profile = qualityProfileDao.selectOrFailByUuid(dbSession, uuid);\n} catch (RowNotFoundException e) {\n  // fall back to key-based lookup or create the profile\n}","preventionTips":["Never hardcode profile UUIDs in scripts/configs; resolve by kee or name each time.","Prefer selectByUuid with explicit null handling when absence is possible.","When copying profiles between instances, re-resolve UUIDs after import."],"tags":["database","resource-not-found","quality-profiles","sonarqube"],"backgroundTag":"record-not-found","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"}