Project

General

Profile

Actions

Defect #36494

closed

WikiContentVersion API returns 500 if author is nil

Added by . ¦3<RELATIVISM . almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Wiki
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Redmine instance. redmine.replicant.us

Redmine returns error 500 on the DeprecatedWikiStart at revision 1:
https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/1.json

While it works at revision 2:
https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/2.json

bugreport in Redmine.

If we look at the history, the revision 1 doesn't have any author:
https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/history?page=10&per_page=25

If we look at the content of the page, redmine reports Anonymous as author:
https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/1

And the page content looks like content automatically generated by Trac (we first used Trac and then OSUOSL kindly migrated us to Redmine which was easier to maintain).

Now, after recent update, that we have the latest Redmine version, the problem still presists so that is why we openned this bugreport here:

Environment:
Redmine version 4.2.3.stable
Ruby version 2.7.5-p203 (2021-11-24) [x86_64-linux]
Rails version 5.2.6
Environment production
[...]


Files

revisions.png (93.2 KB) revisions.png Marius BĂLTEANU, 2022-02-03 07:49
Actions #1

Updated by Go MAEDA almost 3 years ago

Could you paste the error log in production.log (it should be created under /path/to/redmine/log directory) in your Redmine server?

Actions #2

Updated by Marius BĂLTEANU almost 3 years ago

  • Status changed from New to Needs feedback
  • Assignee set to . ¦3<RELATIVISM .
Actions #3

Updated by . ¦3<RELATIVISM . almost 3 years ago

server administrators have been contacted, I should get back to you in a couple days

Actions #4

Updated by . ¦3<RELATIVISM . almost 3 years ago

Hey there ounce again, sorry for the delayed response but Denis was quite busy with RE (Reverse engineering) modem work. So yesterday we (replicant project) were finally able to take care of this.
Go MAEDA and Marius BALTEANU here you go:
"Denis,

Here's the error message from the container logs:

I, [2022-01-31T22:17:24.845018 #1] INFO -- : Started GET
"/projects/replicant/wiki/DeprecatedWikiStart/1.json" for <IP> at
2022-01-31 22:17:24 +0000
I, [2022-01-31T22:17:24.847246 #1] INFO -- : Processing by
WikiController#show as JSON
I, [2022-01-31T22:17:24.847330 #1] INFO -- : Parameters:
{"project_id"=>"replicant", "id"=>"DeprecatedWikiStart", "version"=>"1"}
I, [2022-01-31T22:17:24.853893 #1] INFO -- : Current user: anonymous
I, [2022-01-31T22:17:24.885501 #1] INFO -- : Rendering wiki/show.api.rsb
I, [2022-01-31T22:17:24.901433 #1] INFO -- : Rendered wiki/show.api.rsb
(15.8ms)
I, [2022-01-31T22:17:24.901998 #1] INFO -- : Completed 500 Internal
Server Error in 54ms (ActiveRecord: 12.0ms)
F, [2022-01-31T22:17:24.903798 #1] FATAL -- :
F, [2022-01-31T22:17:24.903876 #1] FATAL -- :
ActionView::Template::Error (undefined method `name' for nil:NilClass):
F, [2022-01-31T22:17:24.904123 #1] FATAL -- : 5: end
6: api.text @content.text
7: api.version @content.version
8: api.author(:id => @content.author_id, :name => @content.author.name)
9: api.comments @content.comments
10: api.created_on @page.created_on
11: api.updated_on @content.updated_on
F, [2022-01-31T22:17:24.904177 #1] FATAL -- :
F, [2022-01-31T22:17:24.904222 #1] FATAL -- :
app/views/wiki/show.api.rsb:8:in `block (2 levels) in
_app_views_wiki_show_api_rsb__1814568556711033433_11882640'
lib/redmine/views/builders/structure.rb:73:in `method_missing'
app/views/wiki/show.api.rsb:1:in `block in
_app_views_wiki_show_api_rsb__1814568556711033433_11882640'
lib/redmine/views/builders.rb:36:in `for'
app/views/wiki/show.api.rsb:1:in
`_app_views_wiki_show_api_rsb__1814568556711033433_11882640'
lib/redmine/sudo_mode.rb:61:in `sudo_mode'

"
Cheers Irelativism
Actions #5

Updated by . ¦3<RELATIVISM . almost 3 years ago

Please change status to "in progress" and maybe asignee GoMAEDA to this issue :). Cheers

Actions #6

Updated by Marius BĂLTEANU almost 3 years ago

Can you post, please, the entire information details from the admin page? I'm interested in the Redmine plugins section as well.

Actions #7

Updated by Marius BĂLTEANU almost 3 years ago

I did now a quick test:
  • Logged with jsmith
  • Created a WikiPage
  • Created two revisions
  • Switch to admin
  • Deleted user jsmith
  • Open the history of the page
  • Both revisions are correctly displayed with Anonymous:
Actions #8

Updated by Marius BĂLTEANU almost 3 years ago

Indeed, this line of code (source:/trunk/app/views/wiki/show.api.rsb#L8) doesn't check if author exists, maybe we should add an extra check. Anyway, in your case, I think the best option is to update that entry in the database and set the User.anonymous.id as author_id@.

Actions #9

Updated by . ¦3<RELATIVISM . almost 3 years ago

I think in our case this is more regarding the migration before we used redmine, so the migration from trac more specifically, given there were sone anonymous contriburions that were transfered into redmine, but maybe not you never know I dont n

Actions #10

Updated by Marius BĂLTEANU almost 3 years ago

  • Status changed from Needs feedback to Closed
  • Assignee deleted (. ¦3<RELATIVISM . )
  • Resolution set to Cant reproduce

. ¦3<RELATIVISM . wrote:

I think in our case this is more regarding the migration before we used redmine, so the migration from trac more specifically, given there were sone anonymous contriburions that were transfered into redmine, but maybe not you never know I dont n

Yes, most probably. I think we can close this.

Actions #11

Updated by . ¦3<RELATIVISM . almost 3 years ago

What!!?! Its obviously quite easy to reproduce this issue just go to https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/1.json, please dont close this issue!! that is a huge disrespect for the time me and GNUtoo spent reporting it, when we could be doing many other usefull stuff for our own projects :s;S. Just because we migrated from Trac doesnt mean this is a problem on our side, it is still a bug with redmine. But its all explained already in description of this report :)

Actions #12

Updated by Marius BĂLTEANU almost 3 years ago

  • Target version set to 4.1.6

. ¦3<RELATIVISM . wrote:

What!!?! Its obviously quite easy to reproduce this issue just go to https://redmine.replicant.us/projects/replicant/wiki/DeprecatedWikiStart/1.json, please dont close this issue!! that is a huge disrespect for the time me and GNUtoo spent reporting it, when we could be doing many other usefull stuff for our own projects :s;S. Just because we migrated from Trac doesnt mean this is a problem on our side, it is still a bug with redmine. But its all explained already in description of this report :)

I was able to reproduce on your instance, but not on a fresh install. As I said in #note-8, it is an inconsistency in your database.

I checked now the table definition and according to the schema, author_id can be null so we will add the extra check in the code.

redmine_development-# \d wiki_contents;
 id         | integer                     |           | not null | nextval('wiki_contents_id_seq'::regclass)
 page_id    | integer                     |           | not null | 
 author_id  | integer                     |           |          | 
 text       | text                        |           |          | 
 comments   | character varying(1024)     |           |          | ''::character varying
 updated_on | timestamp without time zone |           | not null | 
 version    | integer                     |           | not null | 
Actions #13

Updated by Marius BĂLTEANU almost 3 years ago

  • Status changed from Closed to Confirmed
Actions #14

Updated by Marius BĂLTEANU almost 3 years ago

  • Resolution deleted (Cant reproduce)
Actions #15

Updated by . ¦3<RELATIVISM . almost 3 years ago

thanks for reopening issue, I was able to reproduce on redmine.org. So it might not just be a problem with just our instance

Actions #16

Updated by . ¦3<RELATIVISM . almost 3 years ago

here is related error message when running testing scripts:
"
Redmine-page-version: 1" --cleanup=verbatim
Traceback (most recent call last):
File "./testredmine.py", line 306, in <module>
main()
File "./testredmine.py", line 291, in main
git_commit(extension, output_directory, page, file_paths, redmine_instance)
File "./testredmine.py", line 172, in git_commit
sh.git('-C', output_directory, 'commit', *command_args)
File "/usr/lib/python3/dist-packages/sh.py", line 1427, in call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/lib/python3/dist-packages/sh.py", line 774, in init
self.wait()
File "/usr/lib/python3/dist-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/usr/lib/python3/dist-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
"

Actions #17

Updated by Marius BĂLTEANU almost 3 years ago

  • Assignee set to Marius BĂLTEANU
Actions #18

Updated by Marius BĂLTEANU almost 3 years ago

  • Status changed from Confirmed to Resolved
  • Resolution set to Fixed

I've added an extra check for now as we already have in views. Maybe it's better to add also a migration to make the author_id field not null, but we should do it in a later version.

Actions #19

Updated by Marius BĂLTEANU almost 3 years ago

  • Subject changed from "status":500,"error":"Internal Server Error" because of anonymous author to WikiContentVersion API returns 500 if author is nil
  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF