Bug 2030581 - Pass is_markdown when adding comment via attachment update REST API#2591
Conversation
…ate REST API
The update_attachment WebService method does not pass is_markdown to
add_comment(), so comments added through PUT /rest/bug/attachment/{id}
are always rendered as plain text. The web UI path in attachment.cgi
correctly sets is_markdown based on the system use_markdown parameter.
This patch:
- Accepts an optional is_markdown parameter in update_attachment
- Defaults to the system use_markdown setting when not provided
(matching attachment.cgi behavior)
- Passes it through to $bug->add_comment()
- Documents the new parameter in the REST API docs
dklawren
left a comment
There was a problem hiding this comment.
While we are working on this, we should go ahead and fix other comment related methods that do not handle markdown params correctly.
The add_comment WebService method (line 1224-1225) defaults is_markdown to 0 when not provided:
is_markdown => (defined $params->{is_markdown} ? $params->{is_markdown} : 0)
But this PR defaults update_attachment to Bugzilla->params->{use_markdown}. This means the same API caller gets different markdown behavior depending on whether they're using POST /rest/bug/{id}/comment vs PUT /rest/bug/attachment/{id}. The PR
description justifies it as "matching attachment.cgi behavior", which is correct.
Would you be able to make the other places honor the Bugzilla->params->{use_markdown} value as well?
dklawren
left a comment
There was a problem hiding this comment.
After this requested change, we should be good to go.
|
Thanks for the work! |
When using PUT /rest/bug/attachment/{id} with a 'comment' field, the resulting comment is always rendered as plain text, even when the system has use_markdown enabled.
Root cause: the update_attachment method in Bugzilla/WebService/Bug.pm does not pass is_markdown to $bug->add_comment(). The web UI path in attachment.cgi correctly sets is_markdown based on Bugzilla->params->{use_markdown}.
This means there is no way via the REST API to get a Markdown-rendered comment when updating an attachment (e.g. for sec-approval requests where both the questionnaire comment and the sec-approval? flag need to appear as a single entry).
Fix: accept an optional is_markdown parameter in update_attachment, default to the system use_markdown setting when not provided (matching attachment.cgi behavior), and pass it through to $bug->add_comment().
Steps to reproduce:
Expected: The comment should respect is_markdown (or default to the system use_markdown setting).
Actual: is_markdown is never passed to add_comment(); passing it as a top-level parameter causes: "The requested method 'Bugzilla::Attachment::set_is_markdown' was not found."
What this patch does
The update_attachment WebService method does not pass is_markdown to add_comment(), so comments added through PUT /rest/bug/attachment/{id} are always rendered as plain text. The web UI path in attachment.cgi correctly sets is_markdown based on the system use_markdown parameter.
This patch: