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

Arguments passed to an @exposed method as positional and keyword are not refused #1160

Open
sveneberth opened this issue May 10, 2024 · 0 comments
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability discussion These topics must be discussed before completion Priority: Medium This issue may be useful, and needs some attention.

Comments

@sveneberth
Copy link
Member

sveneberth commented May 10, 2024

I just found out you can provide the same argument twice; as positional and keyword. But the positional takes always(?) precedence over the keyword.
I mean this behavior is kind of okay, if it's well documented, but it isn't. And this could cause confisions.
I would rather raise an error if you provide the argument twice -- like the python interpreter would do it.

Here a small example:

@exposed
def demo(
    self,
    arg1: int = 1,
    arg2: int = 2,
):
    return {"arg1": arg1, "arg2": arg2}
Path response
/demo {'arg1': 1, 'arg2': 2}
/demo/7 {'arg1': 7, 'arg2': 2}
/demo?arg1=8 {'arg1': 8, 'arg2': 2}
/demo/7?arg1=8 {'arg1': 7, 'arg2': 2}
@sveneberth sveneberth added bug(fix) Something isn't working or address a specific issue or vulnerability discussion These topics must be discussed before completion Priority: Medium This issue may be useful, and needs some attention. labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability discussion These topics must be discussed before completion Priority: Medium This issue may be useful, and needs some attention.
Projects
None yet
Development

No branches or pull requests

1 participant