Defect #23766

API : creating issues with project identifier no longer possible

Added by Felix Schäfer 7 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:REST API
Target version:3.3.1
Resolution:Fixed Affected version:3.3.0

Description

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.


Related issues

Related to Redmine - Defect #19276: Creating new issues with invalid project_id should return... Closed
Related to Redmine - Defect #20119: REST API: setting project_id in issue not accepted in Red... Closed

Associated revisions

Revision 15855
Added by Jean-Philippe Lang 6 months ago

Let the API accept project identifier for creating issues (#23766).

Patch by Holger Just.

History

#1 Updated by Felix Schäfer 7 months ago

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].

#2 Updated by Felix Schäfer 7 months ago

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.

#3 Updated by Holger Just 7 months ago

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:

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

#4 Updated by Mischa The Evil 7 months ago

Hello Felix and Holger,

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

Greetings, Mischa.

#5 Updated by Felix Schäfer 7 months ago

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 :-)

#6 Updated by Jan from Planio www.plan.io 7 months ago

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!

#7 Updated by Felix Schäfer 7 months ago

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

#8 Updated by Toshi MARUYAMA 6 months ago

  • Target version set to 3.3.1

#9 Updated by Jean-Philippe Lang 6 months ago

  • Subject changed from Regression in issue creation API to API : creating issues with project identifier no longer possible
  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

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.

#10 Updated by Jean-Philippe Lang 6 months ago

  • Status changed from Resolved to Closed

#11 Updated by Felix Schäfer 6 months ago

Thank you :-)

#12 Updated by Go MAEDA 4 months ago

  • Related to Defect #19276: Creating new issues with invalid project_id should return 422 instead of 403 error added

#13 Updated by Go MAEDA 4 months ago

  • Related to Defect #20119: REST API: setting project_id in issue not accepted in Redmine 3.0.3 added

Also available in: Atom PDF