Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spiral/router] Required parameters are not required for uri generation #1162

Open
MartkCz opened this issue Oct 26, 2024 · 2 comments · May be fixed by #1192
Open

[spiral/router] Required parameters are not required for uri generation #1162

MartkCz opened this issue Oct 26, 2024 · 2 comments · May be fixed by #1192
Assignees
Milestone

Comments

@MartkCz
Copy link
Contributor

MartkCz commented Oct 26, 2024

Description

When a parameter is not passed, even though it is required in a route, it is ignored without raising an error.

How To Reproduce

$routes->add('articles.list', '/articles')
    ->callable(fn () => new Response());
$routes->add('articles.detail', '/articles/<id>')
    ->callable(fn () => new Response());

var_dump($router->uri('articles.detail')->getPath()); // == /articles - Better solution is exception or warning
var_dump($router->uri('articles.list')->getPath()); // == /articles
var_dump($router->uri('articles.detail', ['id' => 1])->getPath()); // == /articles/1 
@MartkCz MartkCz added the Bug label Oct 26, 2024
@roxblnfk
Copy link
Member

@butschster hi
Could you comment the issue? Is it a bug or a feature?

@butschster
Copy link
Member

Hey, @MartkCz!!

Thanks for reporting this issue—I've checked it out, and it does seem like a bug!

@butschster hi Could you comment the issue? Is it a bug or a feature?

From what I see, the route pattern should be parsed to identify required parameters, and the URI resolver should validate that all necessary data is provided.

@butschster butschster moved this from Todo to In Progress in Spiral framework Jan 5, 2025
@butschster butschster linked a pull request Jan 6, 2025 that will close this issue
@butschster butschster linked a pull request Jan 6, 2025 that will close this issue
@butschster butschster moved this from In Progress to In review in Spiral framework Jan 6, 2025
@butschster butschster modified the milestones: 4.0, 3.14 Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In review
Development

Successfully merging a pull request may close this issue.

3 participants