X-Nomad-Index correct usage

My goal is to poll for a job’s status using the read job api

This endpoint supports the blocking query mechanism, which I’d like to leverage. However, in the case of an error—specifically when the job is not found (HTTP 404)—the response omits the query metadata, and the X-Nomad-Index is not returned.

See query here:

rtt, resp, err := requireOK(c.doRequest(r)) //nolint:bodyclose // Closing the body is the caller's responsibility.
	if err != nil {
		return nil, err
	}

and the info api here:

func (j *Jobs) Info(jobID string, q *QueryOptions) (*Job, *QueryMeta, error) {
	var resp Job
	qm, err := j.client.query("/v1/job/"+url.PathEscape(jobID), &resp, q)
	if err != nil {
		return nil, nil, err
	}
	return &resp, qm, nil
}

How am I expected to retrieve the index when the job is not found (404)? My goal is to use blocking queries to avoid aggressive polling, but without an index in the error response, it’s unclear how to proceed..

Hi, I’ll post a small fyi, what i ended up doing in my nomadtools watch project is to listen on the stream endpoint for job changes nomad-tools/src/nomad_tools/nomaddbjob.py at main · Kamilcuk/nomad-tools · GitHub . I couldn’t get blocking endpoint to wirk effectively on a busy nomad.