{"record":{"id":"59bb7468aa6742ee","repo":"apache/beam","slug":"invalid-dicom-web-path","errorCode":null,"errorMessage":"Invalid DICOM web path","messagePattern":"Invalid DICOM web path","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/WebPathParser.java","lineNumber":40,"sourceCode":"@SuppressWarnings({\"StringSplitter\"})\npublic class WebPathParser {\n\n  public static class DicomWebPath {\n    public String studyId = \"\";\n    public String seriesId = \"\";\n    public String instanceId = \"\";\n    public String dicomStorePath = \"\";\n    public String project = \"\";\n    public String location = \"\";\n    public String dataset = \"\";\n    public String storeId = \"\";\n  }\n\n  public DicomWebPath parseDicomWebpath(String unparsedWebpath) throws IOException {\n    String[] webPathSplit = unparsedWebpath.split(\"/dicomWeb/\");\n\n    if (webPathSplit.length != 2) {\n      throw new IOException(\"Invalid DICOM web path\");\n    }\n\n    DicomWebPath dicomWebPath = new DicomWebPath();\n\n    dicomWebPath.dicomStorePath = webPathSplit[0];\n    String[] storePathElements = dicomWebPath.dicomStorePath.split(\"/\");\n    dicomWebPath.project = storePathElements[1];\n    dicomWebPath.location = storePathElements[3];\n    dicomWebPath.dataset = storePathElements[5];\n    dicomWebPath.storeId = storePathElements[7];\n\n    String[] searchParameters;\n    searchParameters = webPathSplit[1].split(\"/\");\n    if (searchParameters.length < 2) {\n      throw new IOException(\"Invalid DICOM web path\");\n    }\n    dicomWebPath.studyId = searchParameters[1];\n    dicomWebPath.seriesId = searchParameters[3];","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/WebPathParser.java#L22-L58","documentation":"WebPathParser.parseDicomWebpath splits a DICOM web URL on the literal delimiter '/dicomWeb/' and requires exactly two segments; otherwise it throws IOException('Invalid DICOM web path'). The input is not a recognizable Google Healthcare DICOMweb URL.","triggerScenarios":"Calling parseDicomWebpath (via parsedDicomWebPath/dicomWebPath in DicomIO) with a URL that lacks '/dicomWeb/', contains it multiple times, or has different casing/spacing.","commonSituations":"Passing a plain DICOM store path (projects/.../dicomStores/store) without the /dicomWeb/ suffix; passing an AWS/orthanc DICOMweb URL; double-encoding the URL so '%2FdicomWeb%2F' isn't matched; trailing whitespace.","solutions":["Ensure the path contains the literal segment '/dicomWeb/' exactly once, e.g. projects/p/locations/l/datasets/d/dicomStores/s/dicomWeb/studies/123/series/456/instances/789","Trim and normalize the URL before parsing","Check for URL-encoding of the slashes and decode first","Verify you are not passing only the store path when a full study/series/instance URL is required"],"exampleFix":"// before\nparser.parseDicomWebpath(\"projects/p/locations/l/datasets/d/dicomStores/store/studies/1.2/series/3.4/instances/5.6\");\n// after\nparser.parseDicomWebpath(\"projects/p/locations/l/datasets/d/dicomStores/store/dicomWeb/studies/1.2/series/3.4/instances/5.6\");","handlingStrategy":"validation","validationCode":"java\nstatic boolean isValidDicomWebPath(String url) {\n  return url != null && url.split(\"/dicomWeb/\").length == 2;\n}\nif (!isValidDicomWebPath(unparsedWebpath)) {\n  throw new IllegalArgumentException(\"URL must contain exactly one '/dicomWeb/' segment\");\n}","typeGuard":null,"tryCatchPattern":"java\ntry {\n  DicomWebPath p = parser.parseDicomWebpath(url);\n} catch (IOException e) {\n  if (\"Invalid DICOM web path\".equals(e.getMessage())) {\n    throw new IllegalArgumentException(\"Not a DICOMweb URL: \" + url, e);\n  }\n  throw e;\n}","preventionTips":["Always build URLs including the '/dicomWeb/' literal segment","Trim/decode URLs before parsing","Validate with a regex like ^projects/.+/dicomWeb/studies/.+/series/.+/instances/.+$","Don't pass store-only paths to a parser expecting full DICOMweb resource paths"],"tags":["java","dicom","url-parsing","google-cloud-healthcare"],"backgroundTag":"invalid-url-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}