プロジェクト

全般

プロフィール

Vote #77788

完了

API : creating issues with project identifier no longer possible

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
122
issue_org_id:
23766
author_id:
3866
assigned_to_id:
1
comments:
13
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
110
ステータス-->[Closed]

説明

Since r13999 it is not possible anymore to pass @params[:issue][:project_id]@ to the new issue API anymore. This is still referenced in the API documentation Rest_Issues.


journals

I just realised r13999 only contains half the information to understand this… In r13999 the before filter for @create@ was changed from @IssuesController#find_project@ to @ApplicationController#find_optional_project@. The @issuesController@ method looked for the @project_id@ as @project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])@, but @find_optional_project@ (source:/trunk/app/controllers/application_controller.rb@13999#L304) only looks for @params[:project_id]@.
--------------------------------------------------------------------------------
And as we're still investigating this even more info:

Felix Schäfer wrote:
> it is not possible anymore to pass @params[:issue][:project_id]@ to the new issue API anymore

It was possible to pass @project_id@ as the identifier string before, this is not possible anymore, this only works with numeric IDs now.
--------------------------------------------------------------------------------
The attached patch (with a test) fixes this and restores the behavior of the API as it was before r13999. With this patch, the API again allows to specify the identifier of the project instead of just the numeric ID in the @issue[project_id]@ params key.

This can be reproduced with this curl:

<pre>
curl -v -XPOST http://admin:admin@localhost:3000/issues.json -d '{"issue":{"subject": "Test", "project_id": "test"}}' -H "Content-Type: application/json"
</pre>
--------------------------------------------------------------------------------
Hello Felix and Holger,

FWIW, you might want to take a look at #19276 (and related #20119).

Greetings, Mischa.
--------------------------------------------------------------------------------
Mischa, thanks for the follow-up.

As stated above, albeit not intended this is a regression in the REST API and in our eyes an (unannounced) breaking change. If the rationale to not restore this behaviour breakage is not wanting to write code for it, Holger provided a patch.

If the reason is because it wasn't intended it is not an acceptable changed, such a public API needs to be kept stable. Furthermore, the current behaviour is not consistent. As already noted in #20119 it is still possible to pass an identifier instead of the numeric ID to @params[:project_id]@ but not to @params[:issue][:project_id]@. This means not supporting identifiers in @params[:issue][:project_id]@ is a breaking regression and introduces an inconsistency between these 2 options.

We realise most of these arguments have already been discussed but we feel strongly about not breaking public APIs, even if the previous behaviour was not intended. This will be our last comment on the matter though and we will not discuss this further either way :-)
--------------------------------------------------------------------------------
Felix Schäfer wrote:
> This will be our last comment on the matter though and we will not discuss this further either way :-)

What Felix wanted to say was along the lines of "We won't be nagging about this anymore should the consensus be that the patch is not needed :) We just wanted to add our view on the matter."

We've implemented Holger's Patch at Planio anyways where we believe that consistency for existing users trumps correctness, but we're obviously perfectly fine should the patch not be integrated into Redmine.

Thanks to everyone involved!
--------------------------------------------------------------------------------
I indeed didn't mean to be rude, sorry if it came across that way. Thanks Jan for clarifying.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Fix committed in r15855, thanks. I've moved the test to the API tests to make sure we don't remove/break it in the future.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Thank you :-)
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,19276,Creating new issues with invalid project_id should return 422 instead of 403 error
relates,Closed,20119,REST API: setting project_id in issue not accepted in Redmine 3.0.3

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0