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

actionUser expiry field cannot be set to "infinity" (9223372036854775807) #43

Open
ceefour opened this issue Feb 6, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@ceefour
Copy link

ceefour commented Feb 6, 2021

Reference: https://fusionauth.io/docs/v1/tech/apis/actioning-users/#take-an-action-on-a-user

To cause the action to be applied indefinitely, or until the action is canceled or modified, set this value to 9223372036854775807.

Since Java API uses Long and the expiry field TypeScript definition uses number, trying to use that number literal will give TypeScript warning "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers.ts(80008)"

And also when executing the result is:

Invalid JSON in the request body. The property was [action.expiry]. The error was [Possible conversion error]. The detailed exception was [Numeric value (9223372036854776000) out of range of long (-9223372036854775808 - 9223372036854775807)
 at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 1, column: 181] (through reference chain: io.fusionauth.domain.api.user.ActionRequest["action"]->io.fusionauth.domain.api.user.ActionRequest$ActionData["expiry"])].

Workaround

Use: '9223372036854775807' as any

Proposed Solution

If possible, change the type to number | string | undefined which is probably a good-enough compromise retaining backwards compatibility.

If not possible, then string | undefined is more flexible.

@robotdan robotdan added the bug Something isn't working label Feb 6, 2021
@voidmain
Copy link
Member

voidmain commented Feb 8, 2021

It looks like you might have a typo. The docs state that the max value is 9223372036854775807 but the error you've included says you passed in the value 9223372036854776000. I believe the documentation is correct and as long as the client library passes the value as a JSON number, it should work.

Let me know if I'm missing something on this issue though.

@ceefour
Copy link
Author

ceefour commented Feb 8, 2021

It looks like you might have a typo. The docs state that the max value is 9223372036854775807 but the error you've included says you passed in the value 9223372036854776000. I believe the documentation is correct and as long as the client library passes the value as a JSON number, it should work.

It is easy to check this by using your own local node or your browser's Inspect:

image

That's really the JavaScript/TypeScript problem mentioned there: (this is unique to JS platform and not a problem with Java, Python, etc.)

Numeric literals with absolute values equal to 2^53 or greater are **too large to be represented accurately as integers.**ts(80008)

@voidmain
Copy link
Member

voidmain commented Feb 9, 2021

Ah. Got it now. That's quite the limitation of the JS system and it makes no sense that the system would be rounding UP. That's just crazy talk.

Honestly, I've never been a huge fan of using Long.MAX_VALUE for Infinite actions. I'd prefer to update the FusionAuth code to handle nulls and missing values for expiry.

I did a quick review of the code and it appears that using a value such as 9223372036854775000 should work. The event will contain the duration field, but the rest of the code will function properly.

@ceefour
Copy link
Author

ceefour commented Feb 10, 2021

@voidmain I do agree that expiry == null should mean infinite. But definitely null never means 0 here, as an expiry of 0 don't make sense.

It's still practical to follow your suggestion of a large-enough instant, as for all practical reasons the user would've already been dead anyway by the time his/her user account restriction is lifted. ^_^ (unless his grand-grand-grand-grand-grandchildren cares enough to continue the trolling, hehe)

Update: I just found out the max instant is the year 1000000000. So that's a lot of grandchildren to pass the FusionAuth user account to. ;-) (it'd be cool if someone still uses FusionAuth by then ^_^)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants