{"record":{"id":"ffdfa4d0df21cff2","repo":"SonarSource/sonarqube","slug":"file-not-found","errorCode":"FILE_NOT_FOUND","errorMessage":"Failed to read SARIF report at '%s': %s","messagePattern":"Failed to read SARIF report at '(.+?)': (.+?)","errorType":"exception","errorClass":"SarifDeserializationException","httpStatus":null,"severity":"error","filePath":"sonar-core/src/main/java/org/sonar/core/sarif/SarifSerializerImpl.java","lineNumber":95,"sourceCode":"          public Object handleInstantiationProblem(DeserializationContext ctxt, Class<?> instClass, Object argument, Throwable t) throws IOException {\n            if (!instClass.equals(SarifSchema210.Version.class)) {\n              return NOT_HANDLED;\n            }\n            throw new UnsupportedSarifVersionException(format(UNSUPPORTED_VERSION_MESSAGE_TEMPLATE, argument), t);\n          }\n        })\n        .readValue(reportPath.toFile(), SarifSchema210.class);\n    } catch (UnsupportedSarifVersionException e) {\n      throw new SarifDeserializationException(Category.MAPPING, e.getMessage(), e);\n    } catch (JsonParseException e) {\n      throw new SarifDeserializationException(Category.SYNTAX, format(SARIF_REPORT_ERROR, reportPath, e.getMessage()), e);\n    } catch (JsonMappingException e) {\n      if (e.getMessage() != null && (e.getMessage().contains(\"out of range\") || e.getMessage().contains(\"overflow\"))) {\n        throw new SarifDeserializationException(Category.VALUE, format(SARIF_REPORT_ERROR, reportPath, e.getMessage()), e);\n      }\n      throw new SarifDeserializationException(Category.MAPPING, format(SARIF_REPORT_ERROR, reportPath, e.getMessage()), e);\n    } catch (FileNotFoundException e) {\n      throw new SarifDeserializationException(Category.FILE_NOT_FOUND, format(SARIF_REPORT_ERROR, reportPath, e.getMessage()), e);\n    } catch (IOException e) {\n      throw new IllegalStateException(format(SARIF_REPORT_ERROR, reportPath, e.getMessage()), e);\n    }\n  }\n\n  private static class UnsupportedSarifVersionException extends IOException {\n\n    public UnsupportedSarifVersionException(String message, Throwable t) {\n      super(message, t);\n    }\n  }\n}\n","sourceCodeStart":77,"sourceCodeEnd":108,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/sarif/SarifSerializerImpl.java#L77-L108","documentation":"java.io.FileNotFoundException raised while reading the report is wrapped into SarifDeserializationException with Category.FILE_NOT_FOUND and message 'Failed to read SARIF report at %s: %s'. It means the Path given to SarifSerializerImpl.deserialize does not exist (or, on some platforms, is a directory or is otherwise unopenable) — Jackson's readValue(File,...) opens the file and fails before any JSON parsing happens.","triggerScenarios":"Calling SarifSerializer.deserialize(Path) with a path that does not exist, was deleted between report generation and import, is a directory, or the path string passed via sonar.sarifReportPaths contains a typo/relative path resolved against the wrong working directory.","commonSituations":"sonar.sarifReportPaths configured with a wrong or relative path in CI where the scanner's working directory differs; report generated conditionally and skipped in this build; artifacts cleaned before the SonarQube scan step; case-sensitivity mismatch on Linux for paths authored on Windows/macOS.","solutions":["Check the exact path in the message: verify the file exists at that location (ls/Get-Item) and that the process user can read it","Use an absolute path in sonar.sarifReportPaths or verify the scanner working directory; ensure the report-generation step runs before the SonarQube scan and its artifact is not cleaned","Check case sensitivity and file extension; on Linux, 'Report.SARIF' != 'report.sarif'","In code, call Files.exists(reportPath) / Files.isRegularFile(reportPath) before deserialize and surface a clear message"],"exampleFix":"// before\nPath reportPath = Paths.get(\"reports/scan.sarif\"); // may not exist\nSarifSchema210 sarif = serializer.deserialize(reportPath);\n// after\nPath reportPath = Paths.get(\"reports/scan.sarif\").toAbsolutePath();\nif (!java.nio.file.Files.isRegularFile(reportPath)) {\n  throw new IllegalStateException(\"SARIF report missing: \" + reportPath);\n}\nSarifSchema210 sarif = serializer.deserialize(reportPath);","handlingStrategy":"validation","validationCode":"requireNonNull(reportPath, \"reportPath\");\nif (!Files.isRegularFile(reportPath)) {\n  throw new IllegalArgumentException(\"SARIF report not found: \" + reportPath.toAbsolutePath());\n}","typeGuard":"boolean sarifReportExists(Path p) {\n  return p != null && Files.isRegularFile(p) && Files.isReadable(p);\n}","tryCatchPattern":"try {\n  SarifSchema210 sarif = serializer.deserialize(reportPath);\n} catch (SarifDeserializationException e) {\n  if (e.getCategory() == Category.FILE_NOT_FOUND) {\n    LOG.warn(\"SARIF report {} is missing; skipping import\", reportPath);\n  } else throw e;\n}","preventionTips":["Use absolute paths in sonar.sarifReportPaths; do not rely on the scanner working directory","Ensure the report-generation step completes before the SonarQube scan and artifacts are not cleaned in between","Watch out for case-sensitivity differences between dev (macOS/Windows) and CI (Linux) filesystems","Check Files.exists() as a precondition in custom pipelines"],"tags":["sarif","file-not-found","io","import"],"backgroundTag":"file-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"}