Skip to content

Fix/95 installer rpc route paths - #102

Open
thomasgarrett455 wants to merge 2 commits into
ash-project:mainfrom
thomasgarrett455:fix/95-installer-rpc-route-paths
Open

thomasgarrett455 wants to merge 2 commits into
ash-project:mainfrom
thomasgarrett455:fix/95-installer-rpc-route-paths

Conversation

@thomasgarrett455

Copy link
Copy Markdown

Fixes #95

Problem

On a fresh igniter install the config.exs would get default endpoints but, the router would get
"" as the :run and :validate endpoints, not the default "/rpc/*" endpoints

Root Cause

During the igniter install the new config values are only a pending edit. So, when add_rpc_routes/2 calls Application.get_env/2 it does not have the configured routes.
When no routes are set Application.get_env/2 defaults to nil. Hence, the empty routes in the router file.

The Fix

I added module attributes to the top of the install file to keep config.exs and router fallback in sync.
The 2 literals that were hardcoded in the install file were changed to the attributes. Inside the add_rpc_routes/2
function the defaults are now being passed into Application.get_env/3. These will be used only when
the key isn't already set from the user's configured endpoint.

Tests

Tests were added to ensure:

  • A fresh install will produce the default endpoints,
  • A user with a single endpoint configured will keep that endpoint and get the default endpoint for the other,
  • A user with both endpoints already configured will keep them.
  • A user with an already configured router file will not get duplicate endpoints.

Notes

Apps already installed with this bug won't be repaired because an empty route ("") that was added by a previous
install will still be counted as a route and therefore the installer will use it as an already configured route.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

This branch has not been deployed

No deployments
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.

Igniter installation of ash_typescript always creates invalid routes

1 participant