Project

General

Profile

Actions

Bug #33257

closed

Getting /apidoc/v2.json results in a broken Foreman GUI (500 Internal Server Error)

Added by Manuel Laug over 2 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

When using apipie (e.g. FAM, ...) or getting the apidoc manually with curl, the Foreman GUI is broken afterwards.

This is the error I see in the web interface:

undefined method `minutes' for nil:NilClass

  def set_activity_time
    session[:expires_at] = Setting[:idle_timeout].minutes.from_now.to_i
  end

  def expire_session

This is the error in the logs:

13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354] Started GET "/users/login" for ::1 at 2021-08-13 13:24:17 +0200
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354] Processing by UsersController#login as HTML
[...]
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354]   Rendering users/login.html.erb within layouts/login
13:24:17 rails.1   | 2021-08-13T13:24:17 [W|app|c58e4354] Setting is not initialized yet, requested value for login_text will be always nil
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354]   Rendered common/_login.html.erb (Duration: 1.8ms | Allocations: 194)
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354]   Rendered users/login.html.erb within layouts/login (Duration: 20.0ms | Allocations: 1309)
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354]   Rendering layouts/base.html.erb
13:24:17 rails.1   | 2021-08-13T13:24:17 [W|app|c58e4354] Setting is not initialized yet, requested value for http_proxy will be always nil
[...]
13:24:17 rails.1   | 2021-08-13T13:24:17 [W|app|c58e4354] Setting is not initialized yet, requested value for http_proxy will be always nil
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354]   Rendered layouts/base.html.erb (Duration: 141.7ms | Allocations: 43896)
13:24:17 rails.1   | 2021-08-13T13:24:17 [W|app|c58e4354] Setting is not initialized yet, requested value for idle_timeout will be always nil
13:24:17 rails.1   | 2021-08-13T13:24:17 [I|app|c58e4354] Completed 500 Internal Server Error in 186ms (Views: 174.3ms | ActiveRecord: 1.9ms | Allocations: 48832)
13:24:17 rails.1   |  c58e4354 |
13:24:17 rails.1   |  c58e4354 |
13:24:17 rails.1   | 2021-08-13T13:24:17 [F|app|c58e4354]
13:24:17 rails.1   |  c58e4354 | NoMethodError (undefined method `minutes' for nil:NilClass):
13:24:17 rails.1   |  c58e4354 |
13:24:17 rails.1   |  c58e4354 | app/controllers/concerns/foreman/controller/session.rb:29:in `set_activity_time'
13:24:17 rails.1   |  c58e4354 | app/controllers/concerns/foreman/controller/session.rb:25:in `update_activity_time'
13:24:17 rails.1   |  c58e4354 | app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
13:24:17 rails.1   |  c58e4354 | app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
13:24:17 rails.1   |  c58e4354 | app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
13:24:17 rails.1   |  c58e4354 | lib/foreman/middleware/telemetry.rb:10:in `call'
13:24:17 rails.1   |  c58e4354 | lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
13:24:17 rails.1   |  c58e4354 | lib/foreman/middleware/logging_context_session.rb:22:in `call'
13:24:17 rails.1   |  c58e4354 | lib/foreman/middleware/logging_context_request.rb:11:in `call'

Steps to reproduce:
  • Checkout 2.5-stable branch of Foreman
  • Run migrations/seeding against an empty DB
  • Start Foreman
  • Check the web interface -> still working / login is possible
  • Run curl http://localhost:5000/apidoc/v2.json
  • Check the web interface again -> will be broken now

Environment:
- Foreman 2.5.2 (branch `2.5-stable`)


Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #32489: Setting registry doesn't reload properly on autoreloadClosedOndřej EzrActions
Actions #1

Updated by Tomer Brisker over 2 years ago

Manuel, is this in production or development environment? If it's development it might be a duplicate of #32489.

Actions #2

Updated by Manuel Laug over 2 years ago

  • Status changed from New to Resolved

Tomer Brisker wrote:

Manual, is this in production or development environment? If it's development it might be a duplicate of #32489.

It's a development box. I just tried to reproduce the error again but for some reason, it works today - no idea what changed.
I think we can close this Issue - I will keep an eye on it and test the PR if I hit the problem again.

Actions #3

Updated by Tomer Brisker over 2 years ago

  • Is duplicate of Bug #32489: Setting registry doesn't reload properly on autoreload added
Actions

Also available in: Atom PDF