Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/485#discussion_r107145425
--- Diff:
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
---
@@ -94,9 +113,36 @@ public CatalogItemSummary apply(@Nullable CatalogItem
input) {
};
static Set<String> missingIcons = MutableSet.of();
-
+
@Override
+ public Response createPoly(byte[] item) {
+ Throwable yamlException = null;
+ try {
+ MutableList.copyOf( Yamls.parseAll(new InputStreamReader(new
ByteArrayInputStream(item))) );
+ } catch (Exception e) {
+ Exceptions.propagateIfFatal(e);
+ yamlException = e;
+ }
+
+ if (yamlException==null) {
+ // treat as yaml if it parsed
+ return createFromYaml(new String(item));
+ }
+
+ try {
+ return createFromArchive(item);
+ } catch (Exception e) {
+ throw Exceptions.propagate("Unable to handle input: not YAML
or compatible ZIP. Specify Content-Type to clarify.", e);
--- End diff --
As per @tbouron's comment, this presumably results in the 500 response
code, instead of a 4xx if it wasn't a valid zip?
Can we be more specific - e.g. if it wasn't a zip, then the `yamlException`
may be a more useful response for the user. But that won't be logged.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---