{"record":{"id":"31ae671768cce175","repo":"SonarSource/sonarqube","slug":"mapping","errorCode":"MAPPING","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":86,"sourceCode":"  }\n\n  @Override\n  public SarifSchema210 deserialize(Path reportPath) {\n    try {\n      return mapper\n        .enable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION)\n        .addHandler(new DeserializationProblemHandler() {\n          @Override\n          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);","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/sonar-core/src/main/java/org/sonar/core/sarif/SarifSerializerImpl.java#L68-L104","documentation":"SarifSerializerImpl.deserialize() throws SarifDeserializationException with Category.MAPPING and this message when Jackson fails to map the SARIF file to SarifSchema210 (JsonMappingException not classified as value-range or other specialized categories). This indicates a structural mismatch: the JSON parses but does not match the SARIF 2.1.0 model. Version problems are routed to MAPPING with the version message; range/overflow to VALUE; parse errors to SYNTAX.","triggerScenarios":"Calling deserialize(Path) on a JSON file that is valid JSON but violates the SarifSchema210 contract — wrong property types (e.g. a number where a string is expected), missing required wrappers, or nested structures that don't fit the model, where the mapping exception message isn't an out-of-range/overflow case.","commonSituations":"Pointing the import at a non-SARIF JSON report (e.g. ESLint JSON instead of its SARIF output); a third-party tool emitting SARIF with property type deviations; truncated or hand-edited SARIF files with inconsistent types.","solutions":["Read the embedded cause message to find which JSON property failed to map, and fix that field in the report.","Validate the file against the SARIF 2.1.0 schema (sarif-multitool 'validate' or a JSON-schema validator).","Ensure the file is actually a SARIF report, not another JSON format, before importing.","Regenerate the report with the producing tool updated to emit compliant SARIF 2.1.0."],"exampleFix":"// before: pointing import at wrong file\nsarif.import(\"eslint-report.json\"); // plain JSON, not SARIF\n// after\neslint --format @microsoft/eslint-formatter-sarif --output-file eslint-report.sarif .\nsarif.import(\"eslint-report.sarif\");","handlingStrategy":"try-catch","validationCode":"// cheap structural check before deserialize\nString json = Files.readString(path);\nif (!json.contains(\"\\\"version\\\"\") || !json.contains(\"\\\"runs\\\"\")) {\n  throw new IllegalArgumentException(\"Not a SARIF 2.1.0 report: \" + path);\n}","typeGuard":"boolean looksLikeSarif(Path p) throws IOException {\n  String s = Files.readString(p);\n  return s.contains(\"\\\"version\\\":\") && s.contains(\"\\\"runs\\\":\");\n}","tryCatchPattern":"try {\n  SarifSchema210 sarif = serializer.deserialize(path);\n} catch (SarifDeserializationException e) {\n  switch (e.getCategory()) {\n    case SYNTAX: /* malformed JSON */ break;\n    case VALUE: /* numeric out-of-range */ break;\n    case MAPPING: /* structurally invalid SARIF */ break;\n  }\n}","preventionTips":["Validate reports against the SARIF 2.1.0 JSON schema before import.","Import only SARIF-formatted files (check the version/runs keys).","Catch SarifDeserializationException and branch on Category for precise handling."],"tags":["sarif","deserialization","mapping-failed"],"backgroundTag":"json-unmarshal-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"}