Skip to content

Route name oddities leading to silent failures #101

@parker-codes

Description

@parker-codes

Heyo! First of all, thanks for such a great package. I got it working for the most part on an Adonis v7 project.

I ran into an issue where my API calls were silently failing for a few routes. I eventually realized that the common factor was that these routes all had multi-word route names.

I had originally had my route names like this with camelCase:

router.get("/reports/my-activity", [controllers.Reports, "myActivity"]).as("reports.myActivity");

But after looking through the source code of Tuyau realized that snake_case was the one actually being referenced, so I had to change it to this:

router.get("/reports/my-activity", [controllers.Reports, "myActivity"]).as("reports.my_activity");

When I use camelCase the proxy converts it to snake_case for the registry lookup automatically.

The silent failure was this:

  • I changed the route names to snake_case
  • I also changed the frontend Tuyau usage to snake_case to match, and there were no type errors
  • The frontend calls that used snake_case silently failed, returning nothing
  • I changed only the frontend to use camelCase, and it worked

This makes me believe that the generated frontend types might include both camelCase and snake_case (because there were no type errors), yet the only way it works is if the backend uses snake_case for the route name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions