updated test suite, old zip had some errors between test plan documen…#21
updated test suite, old zip had some errors between test plan documen…#21gwenbleyen87 wants to merge 1 commit intomainfrom
Conversation
…t and ITB test suite
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where vendors' /_search requests through the ITB proxy were resulting in 401 or 404 errors. The changes ensure these calls are properly passed through to Vitalink, providing valid responses without interference.
- Updated the
@RequestMappingannotation to include specific patterns for/_searchendpoints - Refactored request handling logic to properly distinguish between bundle operations and search operations
- Simplified bundle processing and improved resource type detection from path variables
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Your existing bundle logic (unchanged) | ||
| try { | ||
| JsonNode root = objectMapper.readTree(payload.get()); | ||
| JsonNode root = objectMapper.readTree(payload.orElse("{}")); |
There was a problem hiding this comment.
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("")); |
|
|
||
| if ("Bundle".equals(resourceType)) { | ||
| // Special handling for POST /{type}/_search (body is usually form-encoded, not JSON) | ||
| boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$"); |
There was a problem hiding this comment.
The regex pattern ".*/_search/?$" is a magic string that duplicates logic from the @RequestMapping. Consider extracting this pattern to a constant or using a more robust method to detect POST search requests.
| boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$"); | |
| boolean isPostSearch = request.getRequestURI().matches(POST_SEARCH_ENDPOINT_PATTERN); |
| // 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 *."); |
There was a problem hiding this comment.
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 *."); |
Fixed issue for vendors who want to forward /_search requests through the ITB proxy.
Before these calls resulted in ar 401 or a 404. Nog these calls are being passed through towards Vitalink and we get a valid response back, so no interference is needed for vendor software packages.