Skip to content

Commit

Permalink
Protect against possible stray colon in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
marzagao committed Dec 2, 2016
1 parent a56d8da commit db75994
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions provider/elastictranscoder/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,18 @@ func (p *awsProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
Width: aws.Int64Value(resp.Job.Input.DetectedProperties.Width),
}
}
statusMessage := ""
if len(resp.Job.Outputs) > 0 {
statusMessage = aws.StringValue(resp.Job.Outputs[0].StatusDetail)
if strings.Contains(statusMessage, ":") {
errorMessage := strings.SplitN(statusMessage, ":", 2)[1]
statusMessage = strings.TrimSpace(errorMessage)
}
}
return &provider.JobStatus{
ProviderJobID: aws.StringValue(resp.Job.Id),
Status: p.statusMap(aws.StringValue(resp.Job.Status)),
StatusMessage: statusMessage,
Progress: completedJobs / float64(totalJobs) * 100,
ProviderStatus: map[string]interface{}{"outputs": outputs},
SourceInfo: sourceInfo,
Expand Down
2 changes: 2 additions & 0 deletions provider/elastictranscoder/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ func TestAWSJobStatus(t *testing.T) {
expectedJobStatus := provider.JobStatus{
ProviderJobID: jobStatus.ProviderJobID,
Status: provider.StatusFinished,
StatusMessage: "it's finished!",
Progress: 100,
ProviderStatus: map[string]interface{}{
"outputs": map[string]interface{}{
Expand Down Expand Up @@ -752,6 +753,7 @@ func TestAWSJobStatusNoDetectedProperties(t *testing.T) {
expectedJobStatus := provider.JobStatus{
ProviderJobID: jobStatus.ProviderJobID,
Status: provider.StatusFinished,
StatusMessage: "it's finished!",
Progress: 100,
ProviderStatus: map[string]interface{}{
"outputs": map[string]interface{}{
Expand Down

0 comments on commit db75994

Please sign in to comment.