{"record":{"id":"b695da7b991c7888","repo":"SonarSource/sonarqube","slug":"failed-to-read-sarif-report-at-s-s","errorCode":null,"errorMessage":"Failed to read SARIF report at '%s': %s","messagePattern":"Failed to read SARIF report at '(.+?)': (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"sonar-core/src/main/java/org/sonar/core/sarif/SarifSerializerImpl.java","lineNumber":97,"sourceCode":"              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":79,"sourceCodeEnd":108,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/sarif/SarifSerializerImpl.java#L79-L108","documentation":"Any other IOException that is not FileNotFoundException (and not one of the SARIF-specific UnsupportedSarifVersionException cases) is rethrown as an IllegalStateException with message 'Failed to read SARIF report at %s: %s'. This represents unexpected I/O problems while reading the file — permission issues surfaced as other IOExceptions, filesystem/device errors, stream closed, etc. Unlike the category-based SarifDeserializationException cases, it is treated as an unexpected runtime condition (fails the import hard).","triggerScenarios":"SarifSerializerImpl.deserialize(Path) calls readValue(File,...); the underlying FileInputStream or read operation throws an IOException other than FileNotFoundException — e.g. access denied surfacing as a non-FNF IOException on some filesystems, I/O error while reading from a network mount, file deleted mid-read, or an IOException from a custom handler chain.","commonSituations":"Report on a network/ephemeral volume that dropped mid-scan; file permissions changed between check and read; container user lacks read access to the mounted artifact; disk/IO errors on the build agent; races where the file is removed while the scanner reads it.","solutions":["Read the cause chain of the IllegalStateException to identify the underlying IOException; fix that root cause (permissions, mount, disk)","Verify the process user has read permission on the file and every directory in its path (chmod/chown; check ACLs in containers)","Ensure the report lives on stable local storage during the scan; copy it from network shares before importing","Re-run the scan; if the file vanished mid-read, serialize report production and the SonarQube step so the artifact is not concurrently deleted"],"exampleFix":"// before\nSarifSchema210 sarif = serializer.deserialize(reportPath); // IllegalStateException on IO error\n// after\ntry {\n  SarifSchema210 sarif = serializer.deserialize(reportPath);\n} catch (IllegalStateException e) {\n  LOG.error(\"Unreadable SARIF report {}: {}\", reportPath, e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (!Files.isReadable(reportPath)) {\n  throw new AccessDeniedException(reportPath.toString());\n}","typeGuard":"boolean canReadReport(Path p) {\n  try {\n    return p != null && Files.isRegularFile(p) && Files.isReadable(p);\n  } catch (IOException e) {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  SarifSchema210 sarif = serializer.deserialize(reportPath);\n} catch (IllegalStateException e) {\n  Throwable cause = e.getCause();\n  LOG.error(\"I/O failure reading SARIF report {}: {}\", reportPath, cause != null ? cause : e.getMessage());\n  throw e; // treat as unrecoverable environment problem\n}","preventionTips":["Copy reports to local, stable storage before importing instead of reading from network mounts","Verify read permissions for the scanning process user (especially in containers)","Avoid deleting/overwriting the report file while the scan reads it","Monitor build-agent disk health; unexpected IOErrors often indicate hardware/volume issues"],"tags":["sarif","io","illegal-state","filesystem"],"backgroundTag":"file-read-failed","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"}