Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator CLI - Loading of profiles via canonical URL doesn't take into account path params #1685

Open
dotasek opened this issue Jul 12, 2024 · 2 comments
Labels
validation-cli FHIR java validation CLI

Comments

@dotasek
Copy link
Collaborator

dotasek commented Jul 12, 2024

The -profile param has some issues trying to resolve from a canonical URL when the profile hasn't been specified in a loaded IG.

Try running the following with the attached file bp.json:

java -jar validator_cli.jar ./bp.json -version 4.0.1 -profile https://hapi.fhir.org/baseR4/StructureDefinition/profile-example-task-input-no-slice-dmuylwyk -output-style json  

An exception will be thrown:

Exception in thread "main" org.hl7.fhir.exceptions.FHIRException: Unable to find definitions at URL 'https://hapi.fhir.org/baseR4/StructureDefinition/profile-example-task-input-no-slice-dmuylwyk': Bad Request
        at org.hl7.fhir.validation.cli.utils.ProfileLoader.loadProfileFromUrl(ProfileLoader.java:32)
        at org.hl7.fhir.validation.cli.utils.ProfileLoader.loadProfileSource(ProfileLoader.java:18)
        at org.hl7.fhir.validation.ValidationEngine.loadProfile(ValidationEngine.java:553)
        at org.hl7.fhir.validation.cli.tasks.ValidateTask.executeTask(ValidateTask.java:57)
        at org.hl7.fhir.validation.ValidatorCli.readParamsAndExecuteTask(ValidatorCli.java:374)
        at org.hl7.fhir.validation.ValidatorCli.readParamsAndExecuteTask(ValidatorCli.java:171)
        at org.hl7.fhir.validation.ValidatorCli.main(ValidatorCli.java:206)
Caused by: java.io.IOException: Bad Request
        at org.hl7.fhir.utilities.http.HTTPResult.checkThrowException(HTTPResult.java:50)
        at org.hl7.fhir.validation.cli.utils.ProfileLoader.loadProfileFromUrl(ProfileLoader.java:29)
        ... 6 more
Caused by: org.hl7.fhir.utilities.http.HTTPResultException: Invalid HTTP response 400 from https://hapi.fhir.org/baseR4/StructureDefinition/profile-example-task-input-no-slice-dmuylwyk?nocache=1720813749780 (Bad Request) (Response in /var/folders/3g/bqtb98z97c398m9f_b2k3rbc0000gn/T/http-log/fhir-http-2.log)
        at org.hl7.fhir.utilities.http.HTTPResult.checkThrowException(HTTPResult.java:49)
        ... 7 more

One reason for this is that a nocache param gets added to the URL when GETing:

HTTPResult res = ManagedWebAccess.get(src + "?nocache=" + System.currentTimeMillis());

Beyond that, this still won't resolve because by default an HTML file is returned. Attempting to hack past that by appending a \?_format\=json then makes the canonical URL incorrect indicated by -profile unmatchable.

In the documentation, it's clear that the expected path is to load a full IG first. However, this greatly slows simple reproduction, as then IG packaging must get involved instead of simply validating against a single canonical URL.

Can we put some effort into canonical URL resolution for the -profile param?

@dotasek
Copy link
Collaborator Author

dotasek commented Jul 12, 2024

@dmuylwyk

@grahamegrieve
Copy link
Collaborator

I don't understand this bit:

Attempting to hack past that by appending a ?_format=json then makes the canonical URL incorrect indicated by -profile unmatchable.

what doesn't match?

@grahamegrieve grahamegrieve added the validation-cli FHIR java validation CLI label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation-cli FHIR java validation CLI
Projects
None yet
Development

No branches or pull requests

2 participants