Fix HostAuthorization blocking all RSpec request specs #103

Closed
opened 2026-06-04 12:31:24 +00:00 by ldraney · 1 comment
Owner

Type

Bug

Lineage

Standalone — discovered while running RSpec suite for PR #102.

Repo

ldraney/landscaping-assistant

What Broke

Every RSpec request spec returns 403 Forbidden with "Blocked hosts: www.example.com". The test config at config/environments/test.rb:32 has config.hosts.clear, which should allow all hosts, but Rails 8.1's HostAuthorization middleware still rejects www.example.com (RSpec's default request host). This breaks ALL 50+ request specs — only model specs pass.

Error in test output:

Blocked hosts: www.example.com

Repro Steps

  1. Run docker compose exec web bundle exec rspec
  2. Observe: every request spec returns 403 Forbidden
  3. Response body contains Rails "Blocked hosts" error page instead of app content

Expected Behavior

Request specs should reach the application and return normal responses. config.hosts.clear in test.rb should disable host checking entirely.

Environment

  • Cluster/namespace: local Docker dev
  • Service version/commit: Rails 8.1.3, Ruby 3.4.0
  • Related alerts: none — test-only issue

Acceptance Criteria

  • Bug no longer reproduces — bundle exec rspec passes request specs
  • No regression in development or production host config
  • Fix is minimal (1-2 lines in test.rb)
  • PR #102 — where this was discovered
  • config/environments/test.rb:32 — current (broken) host config
### Type Bug ### Lineage Standalone — discovered while running RSpec suite for PR #102. ### Repo `ldraney/landscaping-assistant` ### What Broke Every RSpec request spec returns 403 Forbidden with "Blocked hosts: www.example.com". The test config at `config/environments/test.rb:32` has `config.hosts.clear`, which should allow all hosts, but Rails 8.1's `HostAuthorization` middleware still rejects `www.example.com` (RSpec's default request host). This breaks ALL 50+ request specs — only model specs pass. Error in test output: ``` Blocked hosts: www.example.com ``` ### Repro Steps 1. Run `docker compose exec web bundle exec rspec` 2. Observe: every request spec returns 403 Forbidden 3. Response body contains Rails "Blocked hosts" error page instead of app content ### Expected Behavior Request specs should reach the application and return normal responses. `config.hosts.clear` in test.rb should disable host checking entirely. ### Environment - Cluster/namespace: local Docker dev - Service version/commit: Rails 8.1.3, Ruby 3.4.0 - Related alerts: none — test-only issue ### Acceptance Criteria - [ ] Bug no longer reproduces — `bundle exec rspec` passes request specs - [ ] No regression in development or production host config - [ ] Fix is minimal (1-2 lines in test.rb) ### Related - PR #102 — where this was discovered - `config/environments/test.rb:32` — current (broken) host config
Author
Owner

Scope Review: READY

Review note: review-1315-2026-06-04

Ticket is well-scoped: all bug template sections present, file target verified (config/environments/test.rb:32 contains config.hosts.clear), single-repo fix, 3 verifiable acceptance criteria, no blocking dependencies. 1-point bug fix — no decomposition needed.

Two pre-existing documentation gaps flagged (not blocking):

  • [SCOPE] Add "testing" user story entry to project-landscaping-assistant user-stories section
  • [SCOPE] Create architecture note arch-rails-app (used by 20+ board items)
## Scope Review: READY Review note: `review-1315-2026-06-04` Ticket is well-scoped: all bug template sections present, file target verified (`config/environments/test.rb:32` contains `config.hosts.clear`), single-repo fix, 3 verifiable acceptance criteria, no blocking dependencies. 1-point bug fix — no decomposition needed. Two pre-existing documentation gaps flagged (not blocking): - `[SCOPE]` Add "testing" user story entry to project-landscaping-assistant user-stories section - `[SCOPE]` Create architecture note arch-rails-app (used by 20+ board items)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/landscaping-assistant#103
No description provided.