Skip to content

Commit fa1ee2a

Browse files
committed
handle zero input in testing
1 parent c0bb557 commit fa1ee2a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

coderd/provisionerjobs.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,11 @@ func convertProvisionerJob(pj database.GetProvisionerJobsByIDsWithQueuePositionR
315315
}
316316
job.Status = codersdk.ProvisionerJobStatus(pj.ProvisionerJob.JobStatus)
317317

318-
if err := json.Unmarshal(provisionerJob.Input, &job.Input); err != nil {
319-
job.Input.Error = xerrors.Errorf("decode input: %w", err).Error()
318+
// Only unmarshal input if it exists, this should only be zero in testing.
319+
if len(provisionerJob.Input) > 0 {
320+
if err := json.Unmarshal(provisionerJob.Input, &job.Input); err != nil {
321+
job.Input.Error = xerrors.Errorf("decode input %s: %w", provisionerJob.Input, err).Error()
322+
}
320323
}
321324

322325
return job

0 commit comments

Comments
 (0)