View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0025407 | mantisbt | api rest | public | 2019-01-31 08:20 | 2024-04-22 03:55 |
Reporter | eternalstorms | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Platform | iMac 5k, 2017 | OS | macOS | OS Version | 10.14.2 (18C54) |
Product Version | 2.18.0 | ||||
Target Version | 2.26.2 | ||||
Summary | 0025407: Resetting version fields to empty is not possible | ||||
Description | After having set a "fixed_in_version" value for an issue upon resolving it, when I'd like to re-open that issue, I'd also like to reset "fixed_in_version" to an empty value, because obviously, it wasn't fixed if I had to reopen the issue. I tried passing an empty dictionary a null object: a null-value dictionary: or leaving the dictionary's values empty: nothing worked. For other fields (like handler, or status) using an empty dictionary: | ||||
Additional Information | MantisBT 2.18.0 | ||||
Tags | No tags attached. | ||||
or am I just missing something? |
|
I can reproduce the behavior. It applies not only to fixed_in_version, but to the other version fields as well (version, target_version). Problem seems to be in mc_issue_update() function, which is ignoring null versions instead of unsetting the field. |
|
@dregad I looked at the PR in 0025407:0068843 - the lack of providing the field shouldn't reset the field's value to blank. The update behavior should use a PATCH semantics. The right way to empty a version field is to explicitly set its code |
|
It does not. Consider this test issue
If I update the issue as follows
Note that version and target_version, which are not specified in the payload, are not modified.
PATCH is indeed what is being used here, I'm not sure why you're mentioning that. Can you clarify ?
With a payload like I think my proposed fix
Based on the above, I don't think it's beneficial to be more strict. I'm OK to adapt the code, so that |
|
@dregad I may have misinterpreted the code relating to the patch semantics.
|
|
The anonymous functions I introduced are only here to reduce code duplication, they are not actually changing the semantics. The meaningful change here, is the removal of the But I can add a comment if you want.
Can you clarify your intention ? Is that
OK will do once you have answered the question above. |
|
Actually the PATCH semantics are handled in the parent function rest_issue_update(), which merges the REST payload with the issue data from the DB. But I'll add PHPDoc for the anonymous functions anyway. And also fix a small bug I found while analyzing this ;-) |
|
yes, only empty the field when id = 0 or name = ''. So that is the option I'm suggesting. Note that different languages can serialize json structures differently and generate null values when fields not set, etc. So it would be good to be consistent with the schema and provide standard way to do such behavior.
Just keep in mind that such APIs are typically used from REST and SOAP APIs. |
|
I think this makes things unnecessarily strict, but fine, I'll do as you say. This will require changes in rest_issue_update() to validate input before passing the payload on to mc_issue_update() for processing, to ensure we have no regression on SOAP API.
I would be very surprised if that were the case. Do you have evidence to support that statement ?
Pardon my ignorance, but you have referred to this schema several times and I'm not aware of its existence... Is it something that you manage in Postman ? Can you please point me to where I can find it ?
I see no problem here, as SOAP API does not have the notion of a patch request. mc_issue_update() expects a whole Issue as payload, and if you call it with missing or null fields, they will be cleared. It is the client's responsibility to call mc_issue_get() first to retrieve current values, which is precisely what rest_issue_update() does. |
|