Skip to content

Fix the search and vehicle routes - #35

Merged
HeftyB merged 7 commits into
mainfrom
fix/search-and-dead-routes
Sep 21, 2026
Merged

HeftyB merged 7 commits into
mainfrom
fix/search-and-dead-routes

Conversation

@HeftyB

@HeftyB HeftyB commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Closes #16

Fixes the broken routes in the search and vehicle paths, test-first in both cases.

GET /search returned 500

custId was a primitive long bound to an optional request parameter, so Spring could not represent its absence and the request failed before the handler ran. It is now a Long, checked for null before use, and the optional String parameters default to "" so the isEmpty() checks hold when a parameter is absent. A bare GET /search renders the results page with no matches.

Also removes the isCool request parameter, the System.out.println it triggered, and the "Cool Checkbox" in the search form that sent it, plus five commented-out earlier versions of loops that sit beside the live code.

Two routes pointed at templates that no longer exist

  • GET /admin/create_employee rendered employee_form. Nothing links to it, and the HR administrator page posts its employee form directly to POST /admin/create_employee, which is unchanged, so the GET route is removed.
  • GET /vehicles/search rendered add_new_vehicle when the VIN was blank. A blank search now redirects to the vehicle list.

Every view name returned by a controller now has a template.

The VIN search returned 405

The shared vin-search fragment submits with POST, but only GET /vehicles/search was mapped, so the VIN search on the repair orders page failed. The fragment is also used by the customer page, where the same form posts to a route that creates a record, and its "ADD NEW" button reuses the form to post elsewhere — switching the fragment to GET would break both. The search route accepts either method instead.

Tests

Test Before
GET /search with no parameters renders results IllegalStateException → 500
POST /vehicles/search with a VIN renders the vehicle list 405
A blank VIN search redirects to /vehicles rendered a missing template

Not fixed here

Searching by first and last name with vehicle results still throws ConcurrentModificationException: the list it iterates is the same list it adds to. It is recorded as a known defect in the README rather than fixed, to keep this change small.

🤖 Generated with Claude Code

HeftyB and others added 7 commits September 19, 2026 10:15
Drops the isCool request parameter from SearchController, the
System.out.println it triggered, and the "Cool Checkbox" in the
search form that sent it.

[Ticket: #16]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
custId is a primitive long bound to an optional request parameter,
so Spring cannot represent its absence and a bare GET /search fails
with IllegalStateException before the handler runs.

[Ticket: #16]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bind custId as a Long and check it for null before comparing, and
give the optional String parameters a default of "" so the
isEmpty() checks do not throw when a parameter is absent. A bare
GET /search now renders the results page with no matches.

[Ticket: #16]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- AdminController: remove GET /admin/create_employee, which rendered
  a missing employee_form template. Nothing links to it; the HR
  administrator page posts its employee form directly to
  POST /admin/create_employee, which is unchanged.
- VehicleController: GET /vehicles/search works for a non-blank VIN;
  only its blank-VIN branch rendered a missing add_new_vehicle
  template. A blank search now redirects to the vehicle list. (The
  repair orders page's VIN search form targets this route with POST,
  which it does not accept; that is a separate, unchanged defect.)

Every view name returned by a controller now has a template.

[Ticket: #17]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The shared vin-search fragment submits with POST, but
GET /vehicles/search is the only mapping, so the VIN search on the
repair orders page returns 405. The second test covers the blank-VIN
redirect added earlier in this branch.

[Ticket: #17]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The vin-search fragment is shared with the customer page, where the
same form posts to a route that creates a record, and its ADD NEW
button reuses the form to post elsewhere. Switching the fragment to
GET would break that, so the search route accepts both methods.

[Ticket: #17]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Five earlier versions of loops that the live code beside them
replaced.

[Ticket: #16]

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@HeftyB HeftyB added this to the Portfolio readiness milestone Sep 21, 2026
@HeftyB HeftyB added bug Something isn't working testing Tests and test infrastructure labels Sep 21, 2026
@HeftyB HeftyB self-assigned this Sep 21, 2026
@HeftyB
HeftyB merged commit ef6ee3f into main Sep 21, 2026
1 check passed
@HeftyB
HeftyB deleted the fix/search-and-dead-routes branch September 21, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working testing Tests and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /search returns 500 and contains debug code

1 participant