-
Notifications
You must be signed in to change notification settings - Fork 4
updated test suite, old zip had some errors between test plan documen… #21
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -102,144 +102,125 @@ private String getResourceTypeFromJson(String json, String resourceType) { | |||||||||||
|
|
||||||||||||
| //private String get | ||||||||||||
|
|
||||||||||||
| @RequestMapping({"/proxy", "/proxy/*", "/proxy/*/{id}"}) | ||||||||||||
| @RequestMapping({ | ||||||||||||
| "/proxy", // system-level (e.g., Bundle POST) | ||||||||||||
| "/proxy/{resourceType}", // e.g., /proxy/Patient?name=... | ||||||||||||
| "/proxy/{resourceType}/", // trailing slash | ||||||||||||
| "/proxy/{resourceType}/{id}", // e.g., /proxy/Patient/123 | ||||||||||||
| "/proxy/{resourceType}/_search", // POST-based search | ||||||||||||
| "/proxy/{resourceType}/_search/" // trailing slash | ||||||||||||
| }) | ||||||||||||
| public DeferredResult<ResponseEntity<String>> handleRequest( | ||||||||||||
| HttpServletRequest request, | ||||||||||||
| //@PathVariable(value = "resourceType", required = false) String resourceType, | ||||||||||||
| @PathVariable(value = "id", required = false) Optional<String> resourceId, | ||||||||||||
| @PathVariable(value = "resourceType", required = false) Optional<String> resourceTypeOpt, | ||||||||||||
| @PathVariable(value = "id", required = false) Optional<String> resourceId, | ||||||||||||
| @RequestBody(required = false) Optional<String> payload | ||||||||||||
| ) { | ||||||||||||
| RequestParams proxyRequestParams; | ||||||||||||
| List<Map.Entry<String, RequestParams>> testIds = new ArrayList<>(); | ||||||||||||
|
|
||||||||||||
| // Retrieving the resourceType from the json payload | ||||||||||||
| String resourceType = payload.map(body -> getResourceTypeFromJson(body, "resourceType")).orElse(""); | ||||||||||||
|
|
||||||||||||
| RequestParams proxyRequestParams = null; | ||||||||||||
|
|
||||||||||||
| // Detect if this is a Bundle (system-level POST) | ||||||||||||
| String resourceTypeFromBody = payload.map(b -> getResourceTypeFromJson(b, "resourceType")).orElse(""); | ||||||||||||
| boolean isBundle = "Bundle".equals(resourceTypeFromBody); | ||||||||||||
|
|
||||||||||||
| LOGGER.info("Checking resourceType for Bundle"); | ||||||||||||
| LOGGER.info("Resource type from json \"{}\"", resourceType); | ||||||||||||
| List<Map.Entry<String, RequestParams>> testIds = new ArrayList<>(); | ||||||||||||
| // Resolve resourceType: prefer path variable, fall back to body only for Bundle | ||||||||||||
| String resourceType = resourceTypeOpt.orElse(isBundle ? "Bundle" : ""); | ||||||||||||
|
|
||||||||||||
| if ("Bundle".equals(resourceType)) { | ||||||||||||
| // Special handling for POST /{type}/_search (body is usually form-encoded, not JSON) | ||||||||||||
| boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$"); | ||||||||||||
|
||||||||||||
| boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$"); | |
| boolean isPostSearch = request.getRequestURI().matches(POST_SEARCH_ENDPOINT_PATTERN); |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an empty JSON object "{}" as a fallback when payload is empty could cause issues since Bundle processing expects a proper Bundle structure. Consider using an empty string or handling the empty case explicitly.
| JsonNode root = objectMapper.readTree(payload.orElse("{}")); | |
| JsonNode root = objectMapper.readTree(payload.orElse("")); |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using payload.orElse("{}") when payload is empty will create an empty JSON object, but the subsequent code expects Bundle structure with 'entry' field. This could cause null pointer exceptions or unexpected behavior. The Bundle check should ensure payload is present before processing.
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code logs a warning when resourceType is blank but continues execution. This could lead to downstream errors. Consider returning an appropriate error response or throwing an exception to fail fast.
| // Bail out early with a clear log (or consider mapping to a default/“general” actor). | |
| LOGGER.warn("Resource type is missing. Ensure @RequestMapping uses {resourceType} instead of *."); | |
| // Bail out early with a clear log and error response. | |
| LOGGER.warn("Resource type is missing. Ensure @RequestMapping uses {resourceType} instead of *."); | |
| return ResponseEntity.badRequest().body("Resource type is missing or invalid. Ensure @RequestMapping uses {resourceType} instead of *."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When resourceType is empty (not a Bundle), the downstream code will have issues. Line 173 logs a warning about this, but the code continues execution which may cause the 'actor' error mentioned in the comment. Consider returning an error response early when resourceType cannot be determined.