Skip to content

NumberFormatException when accessing wrong URL path #2981

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

Closed
JanCizmar opened this issue Mar 12, 2025 · 0 comments · Fixed by #3015
Closed

NumberFormatException when accessing wrong URL path #2981

JanCizmar opened this issue Mar 12, 2025 · 0 comments · Fixed by #3015
Labels
bug Something isn't working for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task

Comments

@JanCizmar
Copy link
Contributor

Describe the bug
When user accesses e.g. /v2/projects/export&format=JSON (which is wrong because there is & instead of ?)

the export&format=JSON is matched as the project ID and Tolgee tries to convert it to long.

To Reproduce
Steps to reproduce the behavior:

  1. Execute /v2/projects/export&format=JSON e.g. using CURL
  2. See error

Expected behavior
It would be great if we god 404 with some explanation that project with id export&format=JSON cannot exist. The message should be suggestive enough so the user finds out.

StackTrace

java.lang.NumberFormatException: For input string: "your_tolgee_project_id"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
    at java.lang.Long.parseLong(Long.java:709)
    at java.lang.Long.parseLong(Long.java:832)
    at io.tolgee.security.RequestContextService.getTargetProjectExplicit(RequestContextService.kt:62)
    at io.tolgee.security.RequestContextService.getTargetProject(RequestContextService.kt:48)
    at io.tolgee.security.authorization.ProjectAuthorizationInterceptor.preHandleInternal(ProjectAuthorizationInterceptor.kt:67)
    at io.tolgee.security.authorization.AbstractAuthorizationInterceptor.preHandle(AbstractAuthorizationInterceptor.kt:48)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
...

Versions and environment

  • Tolgee Platform version: [e.g. 2.108.0]
@JanCizmar JanCizmar added bug Something isn't working for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task
Projects
None yet
1 participant