DioxusLabs/dioxus · error

expected path to start with '/'

Error message

expected path to start with '/'

What it means

`RouteParser::new` errors when the path portion of the route literal does not begin with '/'. Server function routes must be absolute paths starting with a slash; a route like `"todos"` instead of `"/todos"` triggers this.

Solutions

  1. Start the route path with `/`, e.g. "/users/{id}".
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/fullstack-macro/src/lib.rs:986 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/6b42c7da5e7a3c2e. Report an issue: GitHub.

Appendix: source

Thrown at packages/fullstack-macro/src/lib.rs:986

}

struct RouteParser {
    path_params: Vec<(Slash, PathParam)>,
    query_params: Vec<QueryParam>,
}

impl RouteParser {
    fn new(lit: LitStr) -> syn::Result<Self> {
        let val = lit.value();
        let span = lit.span();
        let split_route = val.split('?').collect::<Vec<_>>();
        if split_route.len() > 2 {
            return Err(syn::Error::new(span, "expected at most one '?'"));
        }

        let path = split_route[0];
        if !path.starts_with('/') {
            return Err(syn::Error::new(span, "expected path to start with '/'"));
        }
        let path = path.strip_prefix('/').unwrap();

        let mut path_params = Vec::new();

        for path_param in path.split('/') {
            path_params.push((
                Slash(span),
                PathParam::new(path_param, span, Box::new(parse_quote!(())))?,
            ));
        }

        let path_param_len = path_params.len();
        for (i, (_slash, path_param)) in path_params.iter().enumerate() {
            match path_param {
                PathParam::WildCard(_, _, _, _, _, _) => {
                    if i != path_param_len - 1 {
                        return Err(syn::Error::new(

View on GitHub (pinned to 24f6a829df)