gnodet-bot commented on code in PR #26732:
URL: https://github.com/apache/camel/pull/26732#discussion_r4069622887


##########
dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/SchemaHints.java:
##########
@@ -230,6 +236,13 @@ static Error apply(List<Hint> table, Error error, 
YamlValidator validator) {
                         return eip + " holds its EIPs under steps: " + eip + 
": {steps: [- log: \"...\"]}"
                                + (eip.equals("doCatch") ? ", each - doCatch: 
item with exception: and steps:" : "");
                     }),
+            // setBody: {constant: null} to clear the body before a GET: 
constant is a text (CAMEL-24888)
+            append("type", ".*/constant(/expression)?", m -> 
m.message().contains("null found"),
+                    m -> "constant is a text; to set an empty body (a GET 
sends none) write setBody: {simple:"
+                         + " {expression: \"${null}\"}}"),
+            // library: jackson: the enumeration is case sensitive
+            append("enum", ".*/library", ANY,
+                    m -> "the library name is case sensitive: write library: 
Jackson (or Gson, Fastjson, Jsonb)"),

Review Comment:
   ⚠️ **Misleading hint for non-JSON `library` properties**
   
   The `.*/library` location pattern and `ANY` condition make this hint fire 
for **four** distinct `library` properties in the schema — not just JSON:
   
   | Data format | Valid `library` values |
   |---|---|
   | `json` | `Jackson`, `Gson`, `Fastjson`, `Jsonb` |
   | `avro` | `avroJackson`, `Jackson` |
   | `protobuf` | `GoogleProtobuf`, `Jackson` |
   | `yaml` (SnakeYAML) | `SnakeYAML` |
   
   If someone writes `marshal: { avro: { library: avrojackson } }` (wrong 
case), the hint will append "write library: Jackson (or **Gson, Fastjson, 
Jsonb**)" — all three of which are invalid for Avro. Same problem for Protobuf 
and the YAML data format.
   
   The fix is either to scope the location to the JSON data format path 
specifically, or to make the hint message generic (just "the library name is 
case sensitive — valid values are listed in the error above") and let the 
schema error's existing enum-mismatch message carry the actual list:
   
   ```suggestion
               // library: jackson: the enumeration is case sensitive (applies 
to json, avro, protobuf, yaml data formats)
               append("enum", ".*/library", ANY,
                       m -> "the library name is case sensitive"),
   ```
   
   That way the existing schema error message ("jackson is not valid, expected 
one of [Jackson, Fastjson, Gson, Jsonb]") already carries the correct list for 
whichever data format it is, and the hint just explains *why* it doesn't match.



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