View Issue Details

IDProjectCategoryView StatusLast Update
0025996mantisbtapi restpublic2019-08-25 12:36
Reporterdregad Assigned Todregad  
PrioritynormalSeveritytweakReproducibilityalways
Status closedResolutionfixed 
Product Version2.5.0 
Target Version2.22.0Fixed in Version2.22.0 
Summary0025996: Missing tag name in error message when creating issue via REST API
Description

When creating a new issue via REST API with a non-existing tag name, the error message does not include the tag name, which makes it harder to troubleshoot the problem in the payload.

Steps To Reproduce
$ curl --location -w "%{http_code}" --request POST "http://path/to/mantisbt/api/rest/issues/"   --header "Authorization: XXXX"   --header "Content-Type: application/json"   --data "{
  \"summary\": \"Test add issue with tags $(date +%T)\",
  \"description\": \"Test description\",
  \"category\": {
    \"name\": \"General\"
  },
  \"project\": {
    \"name\": \"Test project\"
  }, \"tags\": [ { \"name\": \"xxxx\" }, {} ]
}"

Yields

{"message":"Tag  not found.","code":2200,"localized":"Could not find a tag with that name."}
                ^
                tag name expected here
Additional Information

This problem was also identified by @vboctor in https://github.com/mantisbt/mantisbt/pull/1391#issuecomment-426497674

An orthogonal issue we have is that the tag not found error doesn't include the tag name that isn't found. I haven't changed that as part of this change since this the issue targeted by this issue.

TagsNo tags attached.

Relationships

related to 0024774 closedvboctor Error Creating Issue with new TAG 
related to 0026075 closeddregad Tag-related error messages should reference the tag's name 

Activities

dregad

dregad

2019-08-14 09:00

developer   ~0062567

Last edited: 2019-08-14 09:02

The same problem occurs if the user attempting to create the issue does not have the required privileges to create tags, as the code references an undefined $t_new_tag variable.

{"message":"User '41782' can't create tag ''.","code":2200,"localized":"Could not find a tag with that name."}
                                           ^ 
                                           tag name expected here
dregad

dregad

2019-08-14 10:24

developer   ~0062569

PR https://github.com/mantisbt/mantisbt/pull/1542

Related Changesets

MantisBT: master f2756da0

2019-08-14 03:19

dregad


Details Diff
Add missing tag name in error message

When creating a new issue via REST API with a non-existing tag name,
the error message generated by mci_tag_set_for_issue() did not include
the tag's name.

This was caused by reusing the $t_tag variable to store the return value
of tag_get_by_name(), so the original data is no longer available when
the exception is thrown.

Same problem in IssueAddCommand::validate() if the user attempting to
create the issue does not have the required privileges to create tags,
this time due to usage of an uninitialized variable.

Fixes 0025996
Affected Issues
0025996
mod - api/soap/mc_tag_api.php Diff File
mod - core/commands/IssueAddCommand.php Diff File