-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: API documentation for Task Result type #524
fix: API documentation for Task Result type #524
Conversation
99385c2
to
db11317
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #524 +/- ##
==========================================
- Coverage 99.01% 99.00% -0.01%
==========================================
Files 14 14
Lines 607 605 -2
==========================================
- Hits 601 599 -2
Misses 6 6 ☔ View full report in Codecov by Sentry. |
5e9f876
to
393e7bd
Compare
I'm including #528 in this PR in another commit as it is related to this PR. |
Summarising a chat with Kairo:
Maybe we can consider some simplifications, if they don't disrupt existing clients:
|
Fix documentation about the type of task result in the `/api/v1/tasks`. The type was moved to `Dict[str, Any]` It adds more consistency on task result in the API. Verifying the `message` and `status` and `error` (in case of FAILURE) Signed-off-by: Kairo Araujo <[email protected]>
Include descriptions in the Model (Swagger) documentation. Signed-off-by: Kairo Araujo <[email protected]>
996d49b
to
edbd082
Compare
edbd082
to
8dbd831
Compare
Signed-off-by: Kairo Araujo <[email protected]>
8dbd831
to
ddd900a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes are okay. Feel free to address the two inline comments or not.
Regarding our chat:
- Only mandate task results with
message
field forSUCCESS
,ERROR
,FAILURE
state responses, and do not add them if they are missing in any of the other state responses.- Consolidate
message
anderror
fields forERROR
andFAILURE
.- For
ERROR
themessage
could be a combination of what's currently in both fields, anderror
could be omitted.- For
FAILURE
themessage
could be the exception message, anderror
could be omitted or show the exception type.
Did you consider any of those? I suppose they are improvements that should be done in the worker first.
repository_service_tuf_api/tasks.py
Outdated
task_result = {"message": str(task.result)} | ||
elif task_state == TaskState.SUCCESS and not task_result.get( | ||
task_result = { | ||
"message": f"Task failure: {str(task.result)}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: IMO you can omit "Task failure: ". The info is redundant with the state.
docs/swagger.json
Outdated
"error": { | ||
"type": "string", | ||
"title": "Error", | ||
"description": "If the task status result is `False` shows an error message" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this API user facing documentation? They don't know about task status, right?
Yes, most of them are how the RSTUF Worker sends the task result, not in the API. I noticed also that removing |
Damn. I guess it's also okay to leave it, and ignoring it in the cli first? |
Yes, I will revert it and file issues so we can do it without breaking operability. |
Signed-off-by: Kairo Araujo <[email protected]>
92a8408
to
c55f15c
Compare
Description
Fix documentation about the type of task result in the
/api/v1/tasks
.The type was moved to
Dict[str, Any]
It adds more consistency on task result in the API.
Verifying the
message
andstatus
anderror
(in case of FAILURE)Types of changes
Additional requirements
Code of Conduct
By submitting this PR, you agree to follow our Code of Conduct.