You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance error message for multiple key detection (#2828)
* refactor(validation): enhance error message for multiple key detection
- Updated `ConfigurationParsingException` message to provide clearer guidance on separating APIs and configuration using `---`.
* refactor(parser): improve code formatting, readability, and exception messages
- Adjusted spacing and formatting for better consistency across methods.
- Enhanced clarity of exception messages in `ConfigurationParsingException` and improved handling of multi-document YAML scenarios.
- Streamlined error logs for better debugging during configuration parsing.
* fix(parser): improve exception handling in `GenericYamlParser`
- Added additional context to `ConfigurationParsingException` to enhance debugging (`$ref` key and its context).
* Creates and populates an instance of {@code clazz} from the given YAML/JSON node.
171
173
* - Arrays: only valid for {@code @MCElement(noEnvelope=true)}; items are parsed and passed to the single {@code @MCChildElement} list setter.
172
174
* - Objects: each field is mapped to a setter resolved by {@link MethodSetter#getMethodSetter(ParsingContext, Class, String)};
173
-
* values are produced by {@link MethodSetter#getMethodSetter(ParsingContext, Class, String)}. A top-level {@code "$ref"} injects a previously defined bean.
175
+
* values are produced by {@link MethodSetter#getMethodSetter(ParsingContext, Class, String)}. A top-level {@code "$ref"} injects a previously defined bean.
174
176
* All failures are wrapped in a {@link ConfigurationParsingException} with location information.
@@ -189,7 +191,7 @@ public static <T> T createAndPopulateNode(ParsingContext<?> pc, Class<T> clazz,
189
191
ensureMappingStart(node);
190
192
if (isNoEnvelope(clazz)) {
191
193
log.error("Class {} is annotated with @MCElement(noEnvelope=true), but the YAML/JSON structure does not contain a list.", clazz.getName());
192
-
thrownewConfigurationParsingException("Class %s is annotated with @MCElement(noEnvelope=true), but the YAML/JSON structure does not contain a list.".formatted(clazz.getName()),null,pc);
194
+
thrownewConfigurationParsingException("Class %s is annotated with @MCElement(noEnvelope=true), but the YAML/JSON structure does not contain a list.".formatted(clazz.getName()),null,pc);
193
195
}
194
196
195
197
JsonNoderefNode = node.get("$ref");
@@ -215,9 +217,8 @@ public static <T> T createAndPopulateNode(ParsingContext<?> pc, Class<T> clazz,
if (node.isNull()) thrownewConfigurationParsingException("Collapsed element must not be null.");
249
-
if (node.isArray() || node.isObject()) thrownewConfigurationParsingException("Element is collapsed; expected an inline scalar value, not an %s.".formatted((node.isArray() ? "array" : "object")));
249
+
if (node.isArray() || node.isObject())
250
+
thrownewConfigurationParsingException("Element is collapsed; expected an inline scalar value, not an %s.".formatted((node.isArray() ? "array" : "object")));
0 commit comments