The documentation refers to an additional property called `stateDetails` that can indicate the job state according to the log (warning, info, error etc)
However this never appears for us in the API response. Is it set automatically? Or is it just a placeholder that customers should populate themselves after performing log analysis?
Hi @AllanBowe,
Your reasoning is correct. The stateDetails ONLY returns a value when the job /state is "completed". If you then run a GET /jobExecution/jobs/{{jobID}} and more info is available you'll see the state details. For example, I submitted a job (with SAS code that I know would produce a warning message. Then I sent the call referenced above and I see the following in the response:
"state": "completed",
"stateDetails": "warning",
I hope this clears things up.
Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl
Hi @AllanBowe ,
I got this back from a colleague:
stateDetails is a field the job execution provider (NOT the user) sets - in other words it would get set automatically and is only applicable to the "completed" state.
I'm working on getting some more info.
To investigate the "completed" state when the job fails, the first way to troubleshoot is to run a get on the job:
GET: {{sasserver}}/reportImages/jobs/{{jobid}}
That should provide more info on what happened during the job execution.
Additionally, in the response from the call above, you can locate the log from this endpoint:
Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl
Thanks Joe!
To give some context, we're using this to determine job status when interfacing with the Viya APIs as part of the SASjs CLI, the command looks like this:
sasjs job execute /path/to/my/job -l path/to/job.log --status status.txt
My guess, based on responses, is that the `completed` status is _replaced_ with the `stateDetails` value when errors or warnings are found. Be good to confirm this though.
Hi @AllanBowe,
Your reasoning is correct. The stateDetails ONLY returns a value when the job /state is "completed". If you then run a GET /jobExecution/jobs/{{jobID}} and more info is available you'll see the state details. For example, I submitted a job (with SAS code that I know would produce a warning message. Then I sent the call referenced above and I see the following in the response:
"state": "completed",
"stateDetails": "warning",
I hope this clears things up.
Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl
Here is a complete list of /state values:
Path: | /jobs/{jobId}/state |
---|---|
Returns the following states: pending, running, canceled, completed, or failed.
|
Also, I meant to mention (you may have seen it already) when "stateDetails" returns in the response, the "error" object should return in the response as well with the message. Something like:
},
"state": "completed",
"stateDetails": "warning",
"endTimeStamp": "2020-12-10T14:12:39.506Z",
"heartbeatTimeStamp": "2020-12-10T14:12:34.094Z",
"submittedByApplication": "jobExecution",
"heartbeatInterval": 600,
"elapsedTime": 6114,
"results": {
"COMPUTE_CONTEXT": "SAS Job Execution compute context",
"COMPUTE_JOB": "EA965EB3-DF9D-EB41-A990-6FF54791EE06",
"EA965EB3-DF9D-EB41-A990-6FF54791EE06.log.txt": "/files/files/f650a15e-97ab-4aab-bb77-f0f88eda0e06",
"COMPUTE_SESSION": "8566c785-a142-47f9-b941-f65e256dbd09-ses0000 Ended."
},
"logLocation": "/files/files/ad14e8d0-5e88-45e4-9af5-2564fa052d48",
"error": {
"errorCode": 5710,
"message": "Apparent symbolic reference Y not resolved.",
"links": [],
"version": 2,
"httpStatusCode": 0
},
IOW, the "warning" generated when my code ran in SAS is returned in the "error" "message" object.
Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.