Skip to content

Backport: Validator treat numbers as string in the Query#2607

Closed
predic8 wants to merge 20 commits into
masterfrom
backport-query-numbers-as-string
Closed

Backport: Validator treat numbers as string in the Query#2607
predic8 wants to merge 20 commits into
masterfrom
backport-query-numbers-as-string

Conversation

@predic8
Copy link
Copy Markdown
Member

@predic8 predic8 commented Jan 13, 2026

Summary by CodeRabbit

  • New Features

    • Added node status tracking in load balancing to display per-destination response codes and exceptions
    • Added JSON schema validation with support for external schema references via mappings
    • Enhanced admin interface with node status diagnostics for failed requests
  • Improvements

    • Load balancer automatically falls back to TCP health checks when no health URL is configured
    • Improved validation error messaging for clarity
  • Chores

    • Version bumped to 6.3.15-SNAPSHOT
    • Updated internal routing URL format to "internal://X" syntax

✏️ Tip: You can customize this high-level summary in your review settings.

christiangoerdes and others added 20 commits December 4, 2025 17:16
* feat: json2xml support for arrays

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

* refactor: minor

---------

Co-authored-by: Thomas Bayer <bayer@predic8.de>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
#2471)

* Add support for reference schemas in JSON/YAML schema validation (infrastructure)

* Make `schemas` field private in ReferenceSchemas

* Improve logging for unsupported referenceSchemas in schema validation

* Refactor schema validation logging and add example for JSON schema with reference mappings

* Add tests for JSON schema validation with reference mappings

* improvements
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
* Expand URL handling to support "internal" scheme and improve URI resolution logic in DispatchingInterceptor

* Update internal URL formats to use `internal://` scheme across tests and core implementation

* Roadmap: Remove support for `internal:<name>` syntax in target URLs, retain `internal://` as the valid format.

* Update ROADMAP.md

---------

Co-authored-by: t-burch <119930761+t-burch@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
…2566)

* show load balancer node status (and failure reasons) in adminConsole

* refactor

* added doc

---------

Co-authored-by: Christian Gördes <118011644+christiangoerdes@users.noreply.github.com>
* fix ByteStreamLogging: drop fake zeros

* improve BSL
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
* 6.X: Add default tcp health check

* update doku

---------

Co-authored-by: Thomas Bayer <bayer@predic8.de>
…penAPI validation rules, including regex patterns, enums, and constants. Update related tests and migrate `ArrayExplodeTest` logic to OpenAPI 3.1-specific tests.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR introduces a node status tracking system for load balancing, adds JSON schema validation with reference schema mappings, refactors JSON-to-XML conversion with a new URI-based utility, updates internal routing to use URI-based resolution, and bumps versions from 6.3.11-SNAPSHOT to 6.3.15-SNAPSHOT across the project.

Changes

Cohort / File(s) Summary
Version Bumps (6.3.11-SNAPSHOT → 6.3.15-SNAPSHOT)
annot/pom.xml, core/pom.xml, distribution/pom.xml, distribution/examples/extending-membrane/custom-interceptor/pom.xml, distribution/examples/extending-membrane/embedding-java/pom.xml, distribution/examples/web-services-soap/add-soap-header/pom.xml, distribution/examples/xml/basic-xml-interceptor/pom.xml, distribution/examples/xml/stax-interceptor/pom.xml, maven-plugin/pom.xml, test/pom.xml, war/pom.xml, core/.factorypath, war/.factorypath, membrane.spec, pom.xml (adds swagger-parser 2.1.36)
Parent and dependency version updates across modules; also updates swagger-parser dependency from 2.1.35 to 2.1.36 in root pom.xml.
Node Status Tracking Feature
core/src/main/java/com/predic8/membrane/core/exchange/AbstractExchange.java, core/src/main/java/com/predic8/membrane/core/exchange/Exchange.java, core/src/main/java/com/predic8/membrane/core/interceptor/balancer/ExchangeNodeStatusTracker.java, core/src/main/java/com/predic8/membrane/core/interceptor/balancer/LoadBalancingInterceptor.java
New ExchangeNodeStatusTracker class to track per-destination status during load balancing; AbstractExchange gains nodeStatusTracker field and accessors; Exchange loses old nodeStatusCodes/nodeExceptions arrays; LoadBalancingInterceptor adds trackNodeStatus configuration option.
Load Balancer Health Monitoring
core/src/main/java/com/predic8/membrane/core/interceptor/balancer/BalancerHealthMonitor.java, core/src/main/java/com/predic8/membrane/core/interceptor/balancer/Node.java
BalancerHealthMonitor now performs TCP health check when health URL not configured; adds public tcpHealthy method; Node.javadoc updated to reflect fallback TCP behavior.
JSON Schema Validation
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/json/JSONYAMLSchemaValidator.java, core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/json/SchemaMappings.java
New SchemaMappings class to configure reference schema URN-to-location mappings; ValidatorInterceptor now accepts schemaMappings configuration; JSONYAMLSchemaValidator wires mappings into JsonSchemaFactory initialization.
OpenAPI Validators (Type Constants & String Validation)
core/src/main/java/com/predic8/membrane/core/openapi/validators/SchemaValidator.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/StringRestrictionValidator.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/StringValidator.java
SchemaValidator replaces string-type literals with type constants; StringRestrictionValidator refactored with pattern/enum/const validation and new constructor; StringValidator adds pattern validation, delegates to StringRestrictionValidator, introduces validateFormat helper covering 18+ string formats.
JSON-to-XML Conversion
core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java, core/src/main/java/com/predic8/membrane/core/util/json/JsonToXml.java
New JsonToXml utility class for JSON-to-XML conversion with fluent configuration (rootName, arrayName, itemName); Json2XmlInterceptor refactored to use converter instead of inline JSONObject logic; adds init() method and public accessors for naming configuration.
JsonUtil Package Reorganization
core/src/main/java/com/predic8/membrane/core/util/json/JsonUtil.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/AbstractArrayParameterParser.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ExplodedObjectParameterParser.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ObjectParameterParser.java, core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ScalarParameterParser.java
JsonUtil moved from com.predic8.membrane.core.util to com.predic8.membrane.core.util.json package; all static imports updated accordingly.
HTTP & Retry Tracking
core/src/main/java/com/predic8/membrane/core/transport/http/HttpClient.java, core/src/main/java/com/predic8/membrane/core/transport/http/client/RetryHandler.java
HttpClient and RetryHandler updated to use getNodeStatusTracker() instead of property-based tracking, adding null checks before recording status/exception.
Internal Routing (URI-based Resolution)
core/src/main/java/com/predic8/membrane/core/interceptor/DispatchingInterceptor.java, core/src/test/resources/internal-invocation/proxies.xml, core/src/test/java/com/predic8/membrane/core/interceptor/flow/invocation/internalservice/\\*InternalRoutingTest.java, core/src/test/java/com/predic8/membrane/core/transport/http/ServiceInvocationTest.java
DispatchingInterceptor now treats "internal" targets like "http" and uses URI-based resolution instead of URL; test URLs changed from "internal:X" to "internal://X" format.
Admin UI & REST
core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java, core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java, core/src/main/java/com/predic8/membrane/core/interceptor/administration/DynamicAdminPageInterceptor.java, core/resources/com/predic8/membrane/core/interceptor/administration/docBase/admin/js/membrane.js
AdminPageBuilder adds createExchangeNodeStatusTable() helper; AdminRESTInterceptor adds detail flag to exchange JSON serialization with new writeExchangeDetailFields() helper; DynamicAdminPageInterceptor adds hidden node-status section; JavaScript adds request-node-status dataTable aggregating destinations with status/exception data.
ByteStream Logging
core/src/main/java/com/predic8/membrane/core/transport/http/ByteStreamLogging.java
Uses System.lineSeparator for output formatting; "unencrypted" → "unencryptedly"; logging now conditional on read() result (skips when -1); formatting adjustments for ASCII representation.
OpenAPI Parameter Parsers
core/src/test/java/com/predic8/membrane/core/openapi/oas31/parameters/AbstractArrayExplodeOASXXTest.java, core/src/test/java/com/predic8/membrane/core/openapi/oas30/ArrayExplodeOAS30Test.java, core/src/test/java/com/predic8/membrane/core/openapi/oas31/parameters/ArrayExplodeOAS31Test.java
New abstract test base AbstractArrayExplodeOASXXTest with nested array explode tests; OAS 3.0 and 3.1 test classes added; OAS 3.1 ArrayExplodeTest.java removed and split into versioned classes.
OpenAPI Validator Tests
core/src/test/java/com/predic8/membrane/core/openapi/validators/StringRestrictionValidatorTest.java, core/src/test/java/com/predic8/membrane/core/openapi/validators/StringValidatorTest.java, core/src/test/java/com/predic8/membrane/core/openapi/validators/OpenAPIValidatorTest.java
New comprehensive test suites for StringRestrictionValidator (minLength, maxLength, pattern, enum, const), StringValidator (context-aware validation for BODY vs QUERY_PARAMETER), and OpenAPIValidator (path/method validation, query parameter arrays).
JSON-to-XML Tests
core/src/test/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptorTest.java, core/src/test/java/com/predic8/membrane/core/util/json/JsonToXmlTest.java
Json2XmlInterceptorTest adds tests for custom root, array/item naming, single-element arrays, numbers, and invalid JSON; new JsonToXmlTest adds 12+ test cases covering objects, arrays, primitives, special characters, strange keys, and literal parsing.
Router Scripts & Configuration
distribution/scripts/start_router.sh
Now restricts -D option normalization to only -Dlog4j.configurationFile; other -D options passed unchanged.
JSON Schema Mapping Examples
distribution/examples/validation/json-schema/schema-mappings/*
New example directory with README, proxies.xml (3 APIs with schema validation), schema files (base-param.json, meta.json, schema2000.json, schema2001.json), JSON test payloads (good/bad 2000/2001), and shell/batch startup scripts.
OpenAPI Spec Files
core/src/test/resources/openapi/specs/oas30/array-explode-3.0.X.yaml, core/src/test/resources/openapi/specs/oas31/parameters/array-explode-3.1.X.yaml, core/src/test/resources/openapi/specs/customers.yml
New OAS 3.0.2 and 3.1 array-explode specs with validation constraints (maxLength, minLength, pattern, enum); customers.yml adds ids array query parameter.
Integration Tests
core/src/test/java/com/predic8/membrane/core/openapi/validators/StringTest.java, distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/openapi/OpenAPIValidationExampleTest.java, distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaMappingsExampleTest.java
StringTest updates expected error messages ("regex pattern" → "pattern", enum format); OpenAPIValidationExampleTest updates enum format in assertions; new JSONSchemaMappingsExampleTest validates ports 2000/2001 with schema-mappings example, asserting specific error pointers and Problem Details responses.
Git Configuration
.gitignore
Adds /distribution/conf/apis.yaml and /distribution/conf/membrane.log to ignore patterns.

Sequence Diagram

sequenceDiagram
    participant LB as LoadBalancingInterceptor
    participant EX as Exchange
    participant NST as ExchangeNodeStatusTracker
    participant HC as HttpClient
    participant RH as RetryHandler

    LB->>EX: initNodeStatusTracker()
    EX->>NST: create with destinationCount
    
    loop for each retry attempt
        HC->>HC: dispatch request
        alt Response received
            HC->>NST: setNodeStatusCode(attempt, statusCode)
        else Exception/Retry needed
            RH->>NST: trackNodeException(attempt, e)
        end
    end
    
    EX->>NST: getNodeStatusCodes()
    EX->>NST: getNodeExceptions()
    Note over EX,NST: Data available for admin UI & REST API
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested labels

7.x

Poem

🐰 Whiskers twitch with delight,
Nodes now tracked through their flight,
Schemas mapped, JSON flows,
As the version bump shows,
Six-point-fifteen, shining bright!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0067476 and 8b32cbf.

📒 Files selected for processing (78)
  • .gitignore
  • annot/pom.xml
  • core/.factorypath
  • core/pom.xml
  • core/src/main/java/com/predic8/membrane/core/exchange/AbstractExchange.java
  • core/src/main/java/com/predic8/membrane/core/exchange/Exchange.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/DispatchingInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/administration/DynamicAdminPageInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/balancer/BalancerHealthMonitor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/balancer/ExchangeNodeStatusTracker.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/balancer/LoadBalancingInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/balancer/Node.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/json/JSONYAMLSchemaValidator.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/json/SchemaMappings.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/SchemaValidator.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/StringRestrictionValidator.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/StringValidator.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/AbstractArrayParameterParser.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ExplodedObjectParameterParser.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ObjectParameterParser.java
  • core/src/main/java/com/predic8/membrane/core/openapi/validators/parameters/ScalarParameterParser.java
  • core/src/main/java/com/predic8/membrane/core/transport/http/ByteStreamLogging.java
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpClient.java
  • core/src/main/java/com/predic8/membrane/core/transport/http/client/RetryHandler.java
  • core/src/main/java/com/predic8/membrane/core/util/json/JsonToXml.java
  • core/src/main/java/com/predic8/membrane/core/util/json/JsonUtil.java
  • core/src/main/resources/com/predic8/membrane/core/interceptor/administration/docBase/admin/js/membrane.js
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/invocation/internalservice/AbortInResponseFlowInternalRoutingTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/invocation/internalservice/AbortInternalRoutingTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/invocation/internalservice/RequestResponseInternalRoutingTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/flow/invocation/internalservice/SimpleInternalRoutingTest.java
  • core/src/test/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptorTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/oas30/ArrayExplodeOAS30Test.java
  • core/src/test/java/com/predic8/membrane/core/openapi/oas31/parameters/AbstractArrayExplodeOASXXTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/oas31/parameters/ArrayExplodeOAS31Test.java
  • core/src/test/java/com/predic8/membrane/core/openapi/oas31/parameters/ArrayExplodeTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/validators/OpenAPIValidatorTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/validators/StringRestrictionValidatorTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/validators/StringTest.java
  • core/src/test/java/com/predic8/membrane/core/openapi/validators/StringValidatorTest.java
  • core/src/test/java/com/predic8/membrane/core/transport/http/ServiceInvocationTest.java
  • core/src/test/java/com/predic8/membrane/core/util/JsonUtilTest.java
  • core/src/test/java/com/predic8/membrane/core/util/json/JsonToXmlTest.java
  • core/src/test/resources/internal-invocation/proxies.xml
  • core/src/test/resources/openapi/specs/customers.yml
  • core/src/test/resources/openapi/specs/oas30/array-explode-3.0.X.yaml
  • core/src/test/resources/openapi/specs/oas31/parameters/array-explode-3.1.X.yaml
  • distribution/examples/extending-membrane/custom-interceptor/pom.xml
  • distribution/examples/extending-membrane/embedding-java/pom.xml
  • distribution/examples/validation/json-schema/schema-mappings/README.md
  • distribution/examples/validation/json-schema/schema-mappings/bad2000.json
  • distribution/examples/validation/json-schema/schema-mappings/bad2001.json
  • distribution/examples/validation/json-schema/schema-mappings/good2000.json
  • distribution/examples/validation/json-schema/schema-mappings/good2001.json
  • distribution/examples/validation/json-schema/schema-mappings/membrane.cmd
  • distribution/examples/validation/json-schema/schema-mappings/membrane.sh
  • distribution/examples/validation/json-schema/schema-mappings/proxies.xml
  • distribution/examples/validation/json-schema/schema-mappings/schemas/base-param.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/meta.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/schema2000.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/schema2001.json
  • distribution/examples/web-services-soap/add-soap-header/pom.xml
  • distribution/examples/xml/basic-xml-interceptor/pom.xml
  • distribution/examples/xml/stax-interceptor/pom.xml
  • distribution/pom.xml
  • distribution/scripts/start_router.sh
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/openapi/OpenAPIValidationExampleTest.java
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaMappingsExampleTest.java
  • maven-plugin/pom.xml
  • membrane.spec
  • pom.xml
  • test/pom.xml
  • war/.factorypath
  • war/pom.xml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@predic8 predic8 closed this Jan 13, 2026
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.

3 participants