SonarSource/sonarqube · error · IllegalStateException

Report contains a file with language '%s' but no matching qu

Error message

Report contains a file with language '%s' but no matching quality profile

What it means

ComputeQProfileMeasureStep's visitor, for each file component, reads the file's language key from the report and looks up the Quality Profile registered for that language in analysisMetadataHolder.getQProfilesByLanguage(). If the language has no matching quality profile loaded for the analysis, it throws IllegalStateException 'Report contains a file with language X but no matching quality profile'. Languages with a null language key are skipped (no qprofile for unknown languages), so this only fires for a known-but-unprofiled language.

Source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ComputeQProfileMeasureStep.java:88

    public QProfileAggregationComponentVisitor(Metric qProfilesMetric) {
      super(CrawlerDepthLimit.FILE, POST_ORDER, new SimpleStackElementFactory<QProfiles>() {
        @Override
        public QProfiles createForAny(Component component) {
          return new QProfiles();
        }
      });
      this.qProfilesMetric = qProfilesMetric;
    }

    @Override
    public void visitFile(Component file, Path<QProfiles> path) {
      String languageKey = file.getFileAttributes().getLanguageKey();
      if (languageKey == null) {
        // No qprofile for unknown languages
        return;
      }
      if (!analysisMetadataHolder.getQProfilesByLanguage().containsKey(languageKey)) {
        throw new IllegalStateException("Report contains a file with language '" + languageKey + "' but no matching quality profile");
      }
      path.parent().add(analysisMetadataHolder.getQProfilesByLanguage().get(languageKey));
    }

    @Override
    public void visitDirectory(Component directory, Path<QProfiles> path) {
      QProfiles qProfiles = path.current();
      path.parent().add(qProfiles);
    }

    @Override
    public void visitProject(Component project, Path<QProfiles> path) {
      addMeasure(project, path.current());
    }

    private void addMeasure(Component component, QProfiles qProfiles) {
      if (!qProfiles.profilesByKey.isEmpty()) {
        measureRepository.add(component, qProfilesMetric, qProfiles.createMeasure());

View on GitHub (pinned to 184c821202)

Solutions

  1. Set a default Quality Profile for the language: Administration > Quality Profiles > select the language profile > 'Set as Default' (or POST api/qualityprofiles/set_default)
  2. Re-enable/install the language plugin that provides rules for the language in the report
  3. If the files should not have that language, fix the analyzer configuration (e.g. sonar.sources/sonar.inclusions or file suffixes) so those files are excluded or correctly typed

Example fix

// before: language 'go' in report, no default Go profile
$ sonar-scanner -Dsonar.sources=src  // go files fail CE step
// after: set a default profile via API
curl -u admin:token -X POST 'https://sonar.example.com/api/qualityprofiles/set_default?language=go&qualityProfile=Sonar+way'
// or exclude the files
sonar.exclusions=src/**/*.go
Defensive patterns

Strategy: validation

Validate before calling

// before analysis: ensure every language present in sources has a default profile
for (String lang : languagesInSources(projectDir)) {
  boolean hasDefault = adminApi.qualityProfiles().list().stream()
      .anyMatch(p -> p.language().equals(lang) && p.isDefault());
  if (!hasDefault) throw new IllegalStateException("No default quality profile for language: " + lang);
}

Type guard

static boolean hasProfileFor(String languageKey, Map<String, QProfile> profilesByLanguage) {
  return languageKey != null && profilesByLanguage.containsKey(languageKey);
}

Try / catch

try {
  computeEngine.waitForAnalysis(project);
} catch (IllegalStateException e) {
  if (e.getMessage().contains("but no matching quality profile")) {
    String lang = extractLanguage(e.getMessage());
    adminApi.qualityProfiles().setDefault(lang, "Sonar way"); // or re-enable plugin / fix sonar.sources
  } else throw e;
}

Prevention

When it happens

Trigger: The analyzer report contains files whose languageKey (e.g. 'java', 'py') has no quality profile registered in the analysis metadata — typically because no Quality Profile for that language is set as default, or the plugin providing the language/rules was uninstalled/disabled on the server while old reports or sensors still tag files with that language.

Common situations: Installing a language plugin, analyzing, then disabling the plugin or its profile; a project using a language whose profile was deleted; profiles exist but none is set as default for the language in this SonarQube instance.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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