View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0037370 | mantisbt | attachments | public | 2026-09-05 13:23 | 2026-09-09 19:20 |
| Reporter | dregad | Assigned To | dregad | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | 2.29.0 | ||||
| Target Version | 2.29.0 | Fixed in Version | 2.29.0 | ||
| Summary | 0037370: Misleading error message when trying to delete non-existing attachment via SOAP API | ||||
| Description | Unlike the REST API's `DELETE /issues/{id}/files/{file_id}' which includes the Issue Id, the SOAP API's mc_issue_attachment_delete endpoint only expects the attachment's id and does not allow specifying the issue id. The newly added IssueFileDeleteCommand (0034425) requires both issue_id and file_id; to accomodate this, mc_issue_attachment_delete calls file_get_field() to retrieve the issue id, but does check the return value to ensure that the file actually exists. The Web UI (bug_file_delete.php) does the same thing. So when the attachment does not exist, A more meaningful error message should be returned. | ||||
| Additional Information | Checking for the attachment's existence in the caller is one way to fix this, but it would introduce code duplication. It makes more sense to put this check in IssuefileDeleteCommand::validate(). | ||||
| Tags | No tags attached. | ||||
|
MantisBT: master b444fefc 2026-09-05 10:28 Details Diff |
IssuefileDeleteCommand: accept empty issue id Requiring it makes no sense from SOAP API (mc_issue_attachment_delete() function) or the Web UI (bug_file_delete.php) contexts, because the issue id is unknown to the caller, forcing them to retrieve it using file_get_field(). Problem, file_get_field() returns false when the given id does not exist, so error handling would be required but that is currently not implemented, and the command's validate() returns a misleading error message: "'issue_id' missing". Refactor validate() method to retrieve issue_id from the file record when it is not provided or blank, and return a meaningful error message if not found. If issue_id is given (i.e. from REST API), behavior is u nchanged. Adapt mc_issue_attachment_delete() and bug_file_delete.php: remove unnecessary file_get_field() call and do not pass issue_id to Command. Fixes 0037370 |
Affected Issues 0037370 |
|
| mod - api/soap/mc_issue_attachment_api.php | Diff File | ||
| mod - bug_file_delete.php | Diff File | ||
| mod - core/commands/IssueFileDeleteCommand.php | Diff File | ||