Fixes #39352 - Job inv page ignores remote_execution_job_invocation_report_template setting - #1045
Conversation
030d504 to
427cc0a
Compare
…eport_template setting
427cc0a to
77e71ac
Compare
304e8d7 to
2c1c592
Compare
|
Could we leave the lint fixing to #1043 ? Right now both PRs try to fix that, but with subtle differences. |
2c1c592 to
77e71ac
Compare
| ); | ||
| } | ||
| key: GET_REPORT_TEMPLATE_SETTING, | ||
| url: '/api/settings/remote_execution_job_invocation_report_template', |
There was a problem hiding this comment.
I am not sure, but hopefully @adamruzicka will check that.
I think that user needs view_settings permission to access this endpoint, so basically all "normal" users won't be able to get the response. So we should change backend to return correct template so generate_report_templates permission will be sufficient
There was a problem hiding this comment.
I think that user needs view_settings permission to access this endpoint, so basically all "normal" users won't be able to get the response
That's right, good catch.
So we should change backend to return correct template
Return correct template from where?
There was a problem hiding this comment.
I meant adding something like this to job_invocations/base.json.rabl
if params.key?(:include_permissions)
node :report_template do |invocation|
next unless User.current&.can?(:generate_report_templates)
template = job_report_template
next unless template
job_id_input = template.template_inputs.find_by(name: 'job_id')
next unless job_id_input
{
id: template.id,
job_id_input_id: job_id_input.id,
}
end
end
There was a problem hiding this comment.
Adding what we need to a place where it would be convenient is tempting, but it doesn't really belong there.
What if we introduced a new api endpoint like /api/v2/job_invocations/:id/report which would under the hood render the right template from settings, without ever leaking the setting value to the frontend? Frontend would just check if the user has the generate_report_templates permission, clicking the button would call that endpoint. There would still be some slightly rougher edges, but probably still better than bypassing permissions.
There was a problem hiding this comment.
Yup, I think we can do it like that, do you agree @kmalyjur?
New job invocation page hardcoded
'Job - Invocation Report'instead of reading theremote_execution_job_invocation_report_templatesetting. This fixes it by fetching the setting value via/api/settings/remote_execution_job_invocation_report_templateand using it to search for the template. Falls back to the default if the setting fetch fails.