Better Error Messages for Missing or Extra Parameters for Resource Providers

39 views
Skip to first unread message

mc962

unread,
Mar 29, 2023, 11:24:16 AM3/29/23
to HAPI FHIR
I currently have an application where I'm trying to improve the error messaging around missing or extra parameters passed to a Resource provider.

For example, for an Appointment Resource provider, Search Operation I might test:
1. Missing a parameter annotated as a RequiredParam, such as actor
2. An extra parameter that is not registered, such as extraParam

In both of those cases, I get a 400 with an OperationOutcome code of not-supported, and diagnostics message of "Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[multitenancy_id/Appointment] with parameters [[param1, param2, param3]]".

Is there a way to improve the messaging when missing/extra parameters are provided? This current experience makes it unclear from that request what parameters exactly are missing or extra, and so isn't an ideal experience.

For more information about what my application is configured with, it uses the RestfulServer class, run within a Spring Boot application. It also uses a base url set by the HardcodedServerAddressStrategy and the Multitenancy feature. The hapi-fhir package version is 6.2.1.


mc962

unread,
Mar 29, 2023, 11:30:17 AM3/29/23
to HAPI FHIR
For some more information after digging into the code about why this situation appears to happen:

Passing missing/unregistered extra parameters raises this error because:
- hapi-fhir appears to route requests in RestfulServer in determineResourceMethod, within incomingServerRequestMatchesMethod
- Then I think that the incomingServerRequestMatchesMethod method implementation from the specific Resource binding for that endpoint (e.g. SearchMethodEndpoint), fails to match a route because the submitted parameters don't match what the resource binding expects to have.

There were a few layers of abstraction to dig through so I'm not sure I explained things 100% clearly, but that appears to be the code reason with my current application configuration that led to this. 

I would at least prefer to be able to do something like "Missing required parameter actor", or "Unknown parameter extraParam", or something like that, as I think it would be a lot clearer to the user than the current experience of "This endpoint with this combination of parameters doesn't match anything".

Reply all
Reply to author
Forward
0 new messages