oscerd opened a new pull request, #3075:
URL: https://github.com/apache/camel-kamelets/pull/3075

   Follow-up to #3061 (#929). That change was incomplete and I want to be 
straight about it: it read only half of where a Kamelet can declare its headers.
   
   ## The gap
   
   `getDeclaredHeaders` walked `spec.dataTypes.<in|out>.headers` only. Four 
Kamelets declare their headers one level deeper, inside a data type, and those 
declarations were ignored entirely:
   
   | Kamelet | declares | catalog reported |
   |---|---|---|
   | `slack-source` | 5 CloudEvent headers under 
`out.types.cloudevents.headers` | **0** |
   | `azure-cosmosdb-source` | 5 CloudEvent headers | component fallback |
   | `google-sheets-sink` | 5 GoogleSheets headers | component fallback |
   | `aws-ddb-sink` | `CamelAwsDdbOperation`, `CamelAwsDdbReturnValues` | 
component fallback |
   
   `slack-source` is the plainest: `KameletsCatalogTest` asserted 
`verifyHeaders("slack-source", 0)` — the catalog reported that a Kamelet 
declaring five headers supports none. So #3061 covered 15 of the 19 Kamelets 
that declare anything, and I reported it as done.
   
   ## Fallback, not union — and the #3061 test said so
   
   My first attempt merged the two levels. That took `aws-s3-source` from its 4 
declared S3 headers to 9, by adding the `cloudevents` ones:
   
   ```
   expected: <[CamelAwsS3BucketName, CamelAwsS3ContentType, CamelAwsS3ETag, 
CamelAwsS3Key]>
   but was:  <[CamelAwsS3BucketName, CamelAwsS3ContentType, CamelAwsS3ETag, 
CamelAwsS3Key,
               CamelCloudEventID, CamelCloudEventSource, CamelCloudEventSubject,
               CamelCloudEventTime, CamelCloudEventType]>
   ```
   
   `testDeclaredHeadersWinOverTheComponent`, added in #3061, failed on exactly 
that — which is the rule working. A side-level header is emitted whichever data 
type is in use; a per-type header appears only when its type is selected. 
Unioning them over-reports in precisely the way the component list does, which 
is what #929 was about in the first place.
   
   So the rule is a **per-side fallback**:
   
   1. side declares a top-level `headers` block → that is the answer for that 
side;
   2. otherwise → read what its data types declare;
   3. otherwise → fall back to the component, as before.
   
   `aws-s3-source` is unchanged at 4. The four above now report what they 
declare.
   
   ## Also
   
   `toHeaderModel` takes the fields rather than the object, because the 
side-level and type-level header POJOs are generated separately and share no 
supertype — there is no common interface to program against.
   
   ## Verification
   
   ```
   mvn verify -pl library/camel-kamelets-catalog   ->  EXIT=0, 0 failures
   mvn clean install -DskipTests (root)            ->  EXIT=0, no regen drift
   ```
   
   Two files, no Kamelet YAML touched. The new assertions pin the four counts 
rather than leaving them implied.
   
   ---
   _Claude Code on behalf of Andrea Cosentino_
   


-- 
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