SonarSource/sonarqube · error · RowNotFoundException

Quality profile not found: ${uuid}

Error message

Quality profile not found: ${uuid}

What it means

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.

Source

Thrown at server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java:62

public class QualityProfileDao implements Dao {

  private final System2 system;
  private final UuidFactory uuidFactory;

  public QualityProfileDao(UuidFactory uuidFactory, System2 system) {
    this.uuidFactory = uuidFactory;
    this.system = system;
  }

  @CheckForNull
  public QProfileDto selectByUuid(DbSession dbSession, String uuid) {
    return mapper(dbSession).selectByUuid(uuid);
  }

  public QProfileDto selectOrFailByUuid(DbSession dbSession, String uuid) {
    QProfileDto dto = selectByUuid(dbSession, uuid);
    if (dto == null) {
      throw new RowNotFoundException("Quality profile not found: " + uuid);
    }
    return dto;
  }

  public List<QProfileDto> selectByUuids(DbSession dbSession, List<String> uuids) {
    return executeLargeInputs(uuids, mapper(dbSession)::selectByUuids);
  }

  public List<QProfileDto> selectAll(DbSession dbSession) {
    return mapper(dbSession).selectAll();
  }

  public List<RulesProfileDto> selectBuiltInRuleProfiles(DbSession dbSession) {
    return mapper(dbSession).selectBuiltInRuleProfiles();
  }

  public List<RulesProfileDto> selectBuiltInRuleProfilesWithActiveRules(DbSession dbSession) {
    return mapper(dbSession).selectBuiltInRuleProfilesWithActiveRules();

View on GitHub (pinned to 184c821202)

Solutions

  1. 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.
  2. 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.
  3. If the profile was deleted unintentionally, recreate it or restore it from the instance that owns it, then retry with the new UUID.
  4. If a missing profile is an acceptable case, call selectByUuid instead of selectOrFailByUuid and handle null.

Example fix

// before
QProfileDto profile = qualityProfileDao.selectOrFailByUuid(dbSession, storedUuid);
// after
QProfileDto profile = qualityProfileDao.selectByUuid(dbSession, storedUuid);
if (profile == null) {
  profile = qualityProfileDao.selectByKey(dbSession, profileKey)
      .orElseThrow(() -> new IllegalStateException("Profile not found for key " + profileKey));
}
Defensive patterns

Strategy: try-catch

Validate before calling

QProfileDto existing = qualityProfileDao.selectByUuid(dbSession, uuid);
if (existing == null) {
  throw new IllegalStateException("Profile " + uuid + " not found; fetch key via /api/qualityprofiles/search");
}

Try / catch

try {
  QProfileDto profile = qualityProfileDao.selectOrFailByUuid(dbSession, uuid);
} catch (RowNotFoundException e) {
  // fall back to key-based lookup or create the profile
}

Prevention

When it happens

Trigger: Calling selectOrFailByUuid(dbSession, uuid) with a UUID that does not exist in the QUALITY_PROFILES table (deleted profile, wrong UUID, profile from another instance).

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/72b085a2b27cb07a. Report an issue: GitHub.