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
job.refresh() doesn't exist but is needed (hacky fix included) #2783
Comments
While trying to understand the code to find a better fix for the above, I noticed that |
I don't understand why |
@1ace they're different objects because they're created from different endpoints, and don't necessarily have the same amount of details returned (or even the same attribute structure, as we've found out recently with merge request reviewer details returned from different endpoints). So it could be a bit confusing changing the object attributes dynamically like that. And the GitLab API is too inconsistent for us to assume they could be considered the same type of object IMO. We sort of follow the REST API path segment structure for the most part with this approach. We also document this a bit: This is far from the only case, so if we wanted to be consistent here, we would have to add this path hack to almost every endpoint where similar-but-not-quite-the-same resources are returned. This is why for now we simply document how to get an editable resource when fetched from a different endpoint: However, if |
Description of the problem, including code/CLI snippet
When finding a manual job in a pipeline and deciding to
.play()
it (throughproject.jobs.get(pipeline_job.id).play()
since.play()
is not supported on pipeline jobs), the pipeline job status doesn't get updated.One would think we might need to call
pipelin_job.refresh()
to get the updated status, but this crashes instead, as the method doesn't exist on jobs.Expected Behavior
job.refresh()
refreshes the job data, just likepipeline.refresh()
does.Actual Behavior
Specifications
Looks like
ProjectPipelineJob
is missing theRefreshMixin
, but just adding it doesn't work;refresh()
does aself.manager.gitlab.http_get()
with an incorrect path, and gets a 404 in return.The path used is
/projects/{project_id}/pipelines/{pipeline_id}/jobs/{job_id}
but should be/projects/{project_id}/jobs/{job_id}
.The following crude patch fixes this issue, but someone who understand the
python-gitlab
codebase better than me should be able to fix this cleanly instead 🙂The text was updated successfully, but these errors were encountered: