davsclaus opened a new pull request, #27231:
URL: https://github.com/apache/camel/pull/27231

   **Stacked on #27227 (CAMEL-25194)** — both touch `YamlValidator`; merge that 
one first.
   
   The branches of a pick-one `oneOf` such as `unmarshal` each require their 
own key, so a file that chose one collects "required property X not found" for 
every key it did **not** write. The key it *did* write is missing from that 
list, because its branch got past the required check and failed, if at all, 
further in. `filterOneOfNoise` then keeps one branch for all the places 
validated against the same construct, so a second place inherits the first 
one's winner:
   
   ```yaml
   - choice:
       when:
         - simple: "${header.encoding} == 'JSON'"
           steps: [ { unmarshal: { fhirJson: { fhirVersion: "{{fhirVersion}}" } 
} } ]
         - simple: "${header.encoding} == 'XML'"
           steps: [ { unmarshal: { fhirXml:  { fhirVersion: "{{fhirVersion}}" } 
} } ]
   ```
   ```
   Line 16: /0/.../when/1/steps/0/unmarshal: required property 'fhirJson' not 
found
   ```
   
   The file is correct — `fhirXml` is a data format of `unmarshal` and 
`fhirVersion` is a placeholder the runtime resolves. `fhir-sink.kamelet.yaml` 
of camel-kamelets has exactly this shape, which is where it was found.
   
   ## The change
   
   The `required` errors of a pick-one construct are dropped where the object 
at that place has **something in it**: a branch was chosen, so the others only 
say which keys were not used. An empty object, or a key no branch knows, still 
gets the construct's own error and the unknown-property error — which are the 
ones that tell the author what to do.
   
   ## Why it is this narrow
   
   The general fix — a winner per place rather than one per construct — also 
works, and I measured it: it takes the fhir shape and all 250 kamelets to zero. 
But it costs `YamlValidatorTest.testTypeMismatchFiltersOneOfNoise`, which goes 
from 3 errors to 6. That assertion *is* the filter's purpose, and it fails 
because picking a winner per place stops a place borrowing evidence from 
another place — which is sometimes exactly what produces the clean report. 
Making that work wants the ranking improved first, so it is recorded on the 
issue as its own piece of work rather than attempted here.
   
   ## Verified
   
   - **All 250 out-of-the-box kamelets of camel-kamelets validate clean**, 
where before `fhir-sink` did not.
   - The documentation corpus, the EIP examples and the XML round-trip corpus 
of this module are unchanged — 180 tests green, including 
`testTypeMismatchFiltersOneOfNoise`.
   - `OneOfAlternativesTest` adds five cases: the two-branch fhir shape; one 
branch chosen in several places; choosing nothing is still reported; choosing 
something that is not a data format is still reported; an unrelated typo is 
untouched.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to