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

ValueError: Duplicate 'handler', already handled by <DynamicRoute 'handler' [GET] /v1/handler/ -> <function handler at 0x103c85378> #23

Closed
sloria opened this issue Nov 30, 2015 · 5 comments

Comments

@sloria
Copy link
Contributor

sloria commented Nov 30, 2015

I get a ValueError when passing a name to router.add_route

        cors.add(
            app.router.add_route(method, full_url, handler, name=name),
            {
                '*': aiohttp_cors.ResourceOptions(
                    allow_credentials=True, expose_headers='*', allow_headers='*'
                )
            }

        )

Traceback:

    app = create_app(TestConfig)
api/app.py:27: in create_app
    routes.setup(app)
api/routes.py:26: in setup
    allow_credentials=True, expose_headers='*', allow_headers='*'
../../../miniconda/envs/rero/lib/python3.5/site-packages/aiohttp_cors/__init__.py:193: in add
    route, self._preflight_handler)
../../../miniconda/envs/rero/lib/python3.5/site-packages/aiohttp_cors/urldispatcher_router_adapter.py:45: in add_options_method_handler
    self._router.register_route(new_route)
../../../miniconda/envs/rero/lib/python3.5/site-packages/aiohttp/web_urldispatcher.py:459: in register_route
    .format(name, self._routes[name]))
E   ValueError: Duplicate 'should_i_release', already handled by <DynamicRoute 'should_i_release' [GET] /v1/should_i_release/{username}/{repo}/ -> <function should_i_release at 0x103c85378>

Removing name=name from the call to app.router.add_route removes the error.

@asvetlov
Copy link
Member

I guess it's your code problem.
'should_i_release' route never used by aiohttp_cors itself. Perhaps you are trying to add two different routes with the same name what's obviously wrong.

@rutsky
Copy link
Member

rutsky commented Nov 30, 2015

I can confirm that this is a bug of aiohttp_cors, I will address it soon.

@rutsky
Copy link
Member

rutsky commented Nov 30, 2015

For added CORS routes I copied route name parameter from original route which leaded to this bug.
I fixed it in PR #24 by setting route name to None for CORS routes.

@asvetlov , can you please review that PR? If changes are OK I will release 0.2.0 with fix.

@asvetlov
Copy link
Member

Ahh, got it

@rutsky
Copy link
Member

rutsky commented Nov 30, 2015

@sloria thank you for the bug report. It should be fixed in just released 0.2.0 version.

@asvetlov thanks for the review.

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

No branches or pull requests

3 participants