Skip to content

Commit

Permalink
fix(webhook): Don't try to deserialize fields we don't really n… (#3202
Browse files Browse the repository at this point in the history
…) (#3207)

* fix(webhook): Don't try to deserialize fields we don't really need

An assumption was made that body is a can be jackon parsed into a JSON object.
But that's not always the case, in fact, we actually account for it in the original parse:
https://github.com/spinnaker/orca/blob/master/orca-webhook/src/main/groovy/com/netflix/spinnaker/orca/webhook/tasks/CreateWebhookTask.groovy#L71
But then disregard it in StageContext mapping

This change removes those fields from being parsed since we don't actually need them for anything
inside the stage (they were added in the attempt to be fully typed)

* fixup! fix(webhook): Don't try to deserialize fields we don't really need


Co-authored-by: Emily Burns <emjeburns@gmail.com>
Co-authored-by: Ethan Rogers <ethanfrogers@users.noreply.github.com>
  • Loading branch information
3 people authored and louisjimenez committed Oct 3, 2019
1 parent 2ac45a9 commit 1f96597
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,26 @@ class WebhookStage implements StageDefinitionBuilder {
}

static class WebhookResponseStageData {
String statusEndpoint
Integer statusCodeValue
String statusCode
Map body
WebhookMonitorResponseStageData monitor
String error

// NOTE: The fields below exist in the context because they are inserted by the CreateWebhookTask but they aren't
// consumed by Spinnaker so they are commented out below - they are here for informational purposes only
//String statusEndpoint
//Integer statusCodeValue
//Map body
}

static class WebhookMonitorResponseStageData {
Integer statusCodeValue
String statusCode
Map body
String error
String progressMessage
Number percentComplete

// NOTE: The fields below exist in the context because they are inserted by the MonitorWebhookTask but they aren't
// consumed by Spinnaker so they are commented out below - they are here for informational purposes only
//Integer statusCodeValue
//String statusCode
//Map body
//String progressMessage
//Number percentComplete
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class CreateWebhookTask implements RetryableTask {
}
} catch (JsonParseException | JsonMappingException ex) {
// Just leave body as string, probs not JSON
log.warn("Failed to parse webhook payload as JSON", ex)
}

outputs.webhook << [body: body]
Expand Down

0 comments on commit 1f96597

Please sign in to comment.