hashicorp / hashicorp/nomad

Event stream job payload returns wrong type

Open
#11,367 10 comments 0 reactions 0 assignees View on GitHub
hcc/jira stage/needs-investigation theme/events type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
```
$ nomad version
Nomad v1.1.5 (117a23d2cdf26a1837b21c84f30c8c0f3441e927)
```

### Operating system and Environment details
Amazon Linux 2

### Issue
Using the Go SDK, when processing a Job topic event, we often run into an issue where the SDK fails to marshal the Job event:
```
failed to create job events: failed to read job: 1 error(s) decoding:

* 'Job.Payload': source data must be an array or slice, got string
```

Looking at the payload, the event returns the following:
```
"Payload": "AA==",
```

The full event otherwise has a good structure, the payload is just off.

Go mod dep set at `github.com/hashicorp/nomad/api v0.0.0-20210920221949-6d126ac53cbc`

### Reproduction steps
Use the SDK to subscribe to the event stream with a Job topic filter and process events returned from the stream.

#### Expected Result
A proper `Payload` returned instead of a string. If there is an issue with the event, an error should be returned with the event (`api.Event.Err`).

#### Actual Result
A string `Payload` is returned with no errors reported.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Go SDK event-stream handling for Job topic events and inspect decoding of Job.Payload and reporting through api.Event.Err. Reproduce the issue using the stated Nomad version and subscription steps; done means Payload is returned with the expected type, or a decoding failure is exposed through Event.Err.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.