Skip to content

fix(routes): attach the public invoice middleware through the registrar - #35

Merged
roncodes merged 3 commits into
release/v0.0.13from
fix/public-routes-middleware-group
Oct 14, 2026
Merged

roncodes merged 3 commits into
release/v0.0.13from
fix/public-routes-middleware-group

Conversation

@roncodes

@roncodes roncodes commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes API Contract (Postman) on #32.

#34 wrapped the public invoice routes as ->group(['middleware' => [...]], function ...). RouteRegistrar::group() only takes the callback, so the attributes array reaches Router::group() as the routes argument and is handed to RouteFileRegistrar, which tries to require it:

Array to string conversion in vendor/laravel/framework/src/Illuminate/Routing/RouteFileRegistrar.php:35

Every artisan command and request then fails while the routes load, which is why the contract job died right after optimize:clear. The unit tests never caught it because the test bootstrap's fake registrar accepted an attributes array on group(), which the real one does not.

This attaches the middleware with ->middleware([...]) on the registrar chain, the same way Laravel's registrar does. Routes and middleware are unchanged. The fake registrar in scripts/pest-bootstrap.php now has a middleware() of its own (pending middleware applied to the next group()), so the routes test loads the file and keeps asserting which routes are logged.

Also: run CI on pull requests against release and dev branches. ember.yml, server.yml and postman.yml listed main alone under pull_request.branches, so a fix like this one was only verified once the release PR re-ran. They now match core-api and also run for dev-v* and release/v* targets; this PR's own checks are the proof.

RouteRegistrar::group() takes only the callback. Passing the attributes array
as its first argument made Router::group() treat the array as a routes file,
which fails with 'Array to string conversion' while the routes load and takes
the whole API down. The Postman contract job hit it on release/v0.0.13.
Fixes to a release branch were only verified once the release PR itself re-ran,
because every workflow listed main alone. Match core-api, which already runs
on dev-v* and release/v* targets.
The bootstrap's RouteRegistrar only learned middleware from a group() attributes
array, which is the Router form; the registrar's own middleware() call was
missing, so the routes file could not be loaded in the test once it used it.
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f7de767) to head (c25fefa).

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/v0.0.13       #35   +/-   ##
===================================================
  Coverage             100.00%   100.00%           
  Complexity              1253      1253           
===================================================
  Files                     74        74           
  Lines                   6991      6990    -1     
===================================================
- Hits                    6991      6990    -1     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@roncodes
roncodes merged commit f9a5ccb into release/v0.0.13 Oct 14, 2026
8 checks passed
@roncodes
roncodes deleted the fix/public-routes-middleware-group branch October 14, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant