Skip to content

Conversation

gwenbleyen87
Copy link
Collaborator

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.

@gwenbleyen87 gwenbleyen87 requested review from TomQaliber, bjungs and Copilot and removed request for TomQaliber and bjungs August 26, 2025 17:30
Copilot

This comment was marked as outdated.

@gwenbleyen87 gwenbleyen87 self-assigned this Aug 26, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @RequestMapping annotation to include specific patterns for /_search endpoints
  • 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("{}"));
Copy link

Copilot AI Aug 26, 2025

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.

Suggested change
JsonNode root = objectMapper.readTree(payload.orElse("{}"));
JsonNode root = objectMapper.readTree(payload.orElse(""));

Copilot uses AI. Check for mistakes.


if ("Bundle".equals(resourceType)) {
// Special handling for POST /{type}/_search (body is usually form-encoded, not JSON)
boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$");
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
boolean isPostSearch = request.getRequestURI().matches(".*/_search/?$");
boolean isPostSearch = request.getRequestURI().matches(POST_SEARCH_ENDPOINT_PATTERN);

Copilot uses AI. Check for mistakes.

Comment on lines +172 to +173
// 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 *.");
Copy link

Copilot AI Aug 26, 2025

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.

Suggested change
// 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 *.");

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant