Project

General

Profile

Can't edit or quote issues because of "Unknown Format"

Added by Martin Trenz almost 2 years ago

Hi,

maybe someone here can help me, I'm totally in the woods.

I recently installed Redmine 4.2.10 on my Raspberry Pi under Raspbian (basically Debian 10 "Buster"). In terms of Ruby, Rails, Gems, Passenger etc. it is in no way a "clean" install but a hodgepodge of Rasphian packages and things that got installed by other software or installation howtos (for example the Gems). It may not be possible to replicate the whole setup, and I may have to start from scratch, but I'd like to try to salvage the installation.

The problem occurs when I try to edit (or even quote) an entry on an issue. So, the issue would be a bug, I've opened it with an initial description, than edited it to add more info, made a mistake in that info, and now try to correct it. What I get when hitting the "Edit" button instead is a blank page (and a "Page not found" message when trying to quote, but that is not important to me now). This happens under Apache2/Passenger as well as under webrick, so I think I can rule out Passenger at least.

Here is the relevant part from the logfile:

---snip---
Started GET "/journals/7/edit" for 192.168.0.21 at 2023-03-11 07:29:43 +0100
Processing by JournalsController#edit as HTML
Parameters: {"id"=>"7"}
Current user: admin (id=1)
Completed 406 Not Acceptable in 65ms (ActiveRecord: 15.1ms)

ActionController::UnknownFormat (ActionController::UnknownFormat):

app/controllers/journals_controller.rb:84:in `edit'
lib/redmine/sudo_mode.rb:61:in `sudo_mode'
Started GET "/journals/7/edit" for 192.168.0.21 at 2023-03-11 07:34:36 +0100
Processing by JournalsController#edit as HTML
Parameters: {"id"=>"7"}
Current user: admin (id=1)
Completed 406 Not Acceptable in 56ms (ActiveRecord: 13.4ms)

ActionController::UnknownFormat (ActionController::UnknownFormat):

app/controllers/journals_controller.rb:84:in `edit'
lib/redmine/sudo_mode.rb:61:in `sudo_mode'

---snip---

Everything else seems to be working fine as far as I've seen by now. So, I have a few stupid questions:

- Is this related to Ruby, Rails, or Redmine itself? Where should I dig deeper?
- The offending statement is "format.js", but that seems to be used all over Redmine, why does it not work here?
- Am I missing a Gem or something that would implement "format.js" for this specific tasks?
- Could it be a conflict of versions between Ruby, Rails, Gems and Redmine?
- Any other ideas or tips that I could try?

Thank you all for your help. As I've said I'm totally at sea here, after 30+ years in IT :-)


Replies (4)

RE: Can't edit or quote issues because of "Unknown Format" - Added by Mayama Takeshi almost 2 years ago

Hi,
I'm not a redmine core dev but I've been studying redmine/rails in my spare time.

Anyway, I'm using redmine 5.
I checked the code and I can see it is the same as for redmine 4:

  def edit
    (render_403; return false) unless @journal.editable_by?(User.current)
    respond_to do |format|
      # TODO: implement non-JS journal update
      format.js
    end
  end

I understand the above means this method will only support requests as JS.

For comparison, the subsequent method update supports both HTML and JS:

  def update
    (render_403; return false) unless @journal.editable_by?(User.current)
    @journal.safe_attributes = params[:journal]
    @journal.save
    @journal.destroy if @journal.details.empty? && @journal.notes.blank?
    call_hook(:controller_journals_edit_post, {:journal => @journal, :params => params})
    respond_to do |format|
      format.html {redirect_to issue_path(@journal.journalized)}
      format.js
    end
  end

Then, while you get:

Started GET "/journals/7/edit" for 192.168.0.21 at 2023-03-11 07:29:43 +0100
Processing by JournalsController#edit as HTML
... ABRIGED ...
Completed 406 Not Acceptable in 56ms (ActiveRecord: 13.4ms)

I get:

Started GET "/journals/778/edit" for 192.168.181.113 at 2023-03-11 20:22:21 +0900
Processing by JournalsController#edit as JS
... ABRIDGED ...
Completed 200 OK in 24ms (Views: 6.9ms | ActiveRecord: 3.4ms | Allocations: 8014)

So I would try to understand why you get "edit as HTML" instead of "edit as JS".

RE: Can't edit or quote issues because of "Unknown Format" - Added by Mayama Takeshi almost 2 years ago

According to ChatGPT, the format of the request would be either specified by a suffix in the HTTP request URL or by the Accept header.
In my case I have:

GET /journals/778/edit HTTP/1.1.
Host: 192.168.225.201:3000.
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0.
Accept: text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01.

So that is why I get 'edit as JS'. So I would check the headers of your request and this would probably confirm that you are requesting HTML format.

RE: Can't edit or quote issues because of "Unknown Format" - Added by Martin Trenz almost 2 years ago

Oh my, where can I hide my face...

Your tip was golden. The reason Redmine tried to do HTML was that I use the "NoScript" extension for Firefox which - by default - blocks all JS. By allowing the "myredmine" VHOST to execute JS in FF the problem went away, I had simply forgotten to configure that (and Redmine didn't complain upon startup/login, might be something to check in the future). Might've been that I was a bit overwhelmed with all the parts "under the hood" to look for a possible client-side problem :-)

Thank you very, very much for your help!

RE: Can't edit or quote issues because of "Unknown Format" - Added by Benny Hughes over 1 year ago

Thank you for clearing my mind, I was a little confused before. You saved my day.

    (1-4/4)