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

stat.ink API Error "Rank After Exp must be no less than 0." #36

Closed
tako774 opened this issue Nov 28, 2022 · 12 comments · Fixed by #37 or #58
Closed

stat.ink API Error "Rank After Exp must be no less than 0." #36

tako774 opened this issue Nov 28, 2022 · 12 comments · Fixed by #37 or #58
Assignees
Labels
bug Something isn't working

Comments

@tako774
Copy link

tako774 commented Nov 28, 2022

Describe the bug
Reporting to stat.ink causes API error { error: { rank_after_exp: "Rank After Exp must be no less than 0." } }, (maybe) after success of Rank-Up Battle.
Reproducing profile.json did not work.

To Reproduce

  1. Succeed 3 wins at Rank-Up Battle (I did S+19 -> S+20)
  2. Report with command deno run -Ar https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/s3si.ts

Expected behavior
Reporting with no error.

Screenshots or Links

> deno run -Ar https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/s3si.ts
Fetching battle list...
Export vs games
[                                                  ] stat.ink 0.00% 1.5s eta: - 0/3

APIError: Failed to export battle
Response:  Response {
  body: ReadableStream { locked: true },
  bodyUsed: true,
  headers: Headers {
  "accept-ch": "UA, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform, UA-Platform-Version",
  "access-control-allow-origin": "*",
  "alt-svc": 'h3=":443"; ma=86400, h3-29=":443"; ma=86400',
  "cache-control": "no-store, no-transform",
  "cf-cache-status": "DYNAMIC",
  "cf-ray": "7712a5399fd0af36-NRT",
  "content-type": "application/json; charset=UTF-8",
  date: "Mon, 28 Nov 2022 11:08:24 GMT",
  expires: "Thu, 19 Nov 1981 08:52:00 GMT",
  nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
  "permissions-policy": "interest-cohort=()",
  pragma: "no-cache",
  "report-to": '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=m0Xx0IUwom3uViuwpWwGJUFQzwnpwTqS2...',
  server: "cloudflare",
  "set-cookie": "_csrf=88821475e4b91016d30099f751379bc193bd12513223e54ccb264815e9519fd1a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22...",
  "strict-transport-security": "max-age=15552000; includeSubDomains; preload",
  "x-content-type-options": "nosniff",
  "x-frame-options": "SAMEORIGIN",
  "x-powered-by": "PHP/8.0.26",
  "x-ua-compatible": "IE=Edge",
  "x-xss-protection": "1;mode=block"
},
  ok: false,
  redirected: false,
  status: 400,
  statusText: "Bad Request",
  url: "https://stat.ink/api/v3/battle"
}
Body:  { error: { rank_after_exp: "Rank After Exp must be no less than 0." } }

Failed to export to stat.ink: Error: Failed to export battle
    at StatInkAPI.postBattle (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/exporters/stat.ink.ts:90:13)
    at async StatInkExporter.exportGame (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/exporters/stat.ink.ts:242:23)
    at async step (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:323:23)
    at async App.exportGameList (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:338:9)
    at async showError (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/utils.ts:75:12)
    at async Promise.all (index 0)
    at async App.exportOnce (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:152:7)
    at async App.run (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:282:7)
    at async showError (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/utils.ts:75:12)
    at async https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/s3si.ts:44:1

Exported stat.ink: 0


APIError: Failed to export battle
Response:  Response {
  body: ReadableStream { locked: true },
  bodyUsed: true,
  headers: Headers {
  "accept-ch": "UA, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform, UA-Platform-Version",
  "access-control-allow-origin": "*",
  "alt-svc": 'h3=":443"; ma=86400, h3-29=":443"; ma=86400',
  "cache-control": "no-store, no-transform",
  "cf-cache-status": "DYNAMIC",
  "cf-ray": "7712a5399fd0af36-NRT",
  "content-type": "application/json; charset=UTF-8",
  date: "Mon, 28 Nov 2022 11:08:24 GMT",
  expires: "Thu, 19 Nov 1981 08:52:00 GMT",
  nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}',
  "permissions-policy": "interest-cohort=()",
  pragma: "no-cache",
  "report-to": '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=m0Xx0IUwom3uViuwpWwGJUFQzwnpwTqS2...',
  server: "cloudflare",
  "set-cookie": "_csrf=88821475e4b91016d30099f751379bc193bd12513223e54ccb264815e9519fd1a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22...",
  "strict-transport-security": "max-age=15552000; includeSubDomains; preload",
  "x-content-type-options": "nosniff",
  "x-frame-options": "SAMEORIGIN",
  "x-powered-by": "PHP/8.0.26",
  "x-ua-compatible": "IE=Edge",
  "x-xss-protection": "1;mode=block"
},
  ok: false,
  redirected: false,
  status: 400,
  statusText: "Bad Request",
  url: "https://stat.ink/api/v3/battle"
}
Body:  { error: { rank_after_exp: "Rank After Exp must be no less than 0." } }
error: Uncaught (in promise) Error: Failed to export battle
      throw new APIError({
            ^
    at StatInkAPI.postBattle (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/exporters/stat.ink.ts:90:13)
    at async StatInkExporter.exportGame (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/exporters/stat.ink.ts:242:23)
    at async step (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:323:23)
    at async App.exportGameList (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:338:9)
    at async showError (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/utils.ts:75:12)
    at async Promise.all (index 0)
    at async App.exportOnce (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:152:7)
    at async App.run (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/app.ts:282:7)
    at async showError (https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/src/utils.ts:75:12)
    at async https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/s3si.ts:44:1

Environment (please complete the following information):

  • OS: Windows 10
  • Deno version 1.28.2 (release, x86_64-pc-windows-msvc)
  • Version 0.1.32
@tako774
Copy link
Author

tako774 commented Nov 28, 2022

In exported file, rankState.rankPoint = -1

"rankState":{"gameId":"6b15fa4b-83a8-5ff4-b224-db71bf7e883f","rank":"S+19","rankPoint":-1},"rankBeforeState":{"gameId":"a4d164fc-31c9-5655-becc-9f366719202c","rank":"S+19","rankPoint":-1}

@spacemeowx2 spacemeowx2 added the bug Something isn't working label Nov 28, 2022
@spacemeowx2
Copy link
Owner

I'm sorry this happened, and I will look into how to solve this problem as soon as possible. Please try not to play more than 50 games during this period, otherwise data may be lost.

@spacemeowx2 spacemeowx2 self-assigned this Nov 28, 2022
spacemeowx2 added a commit that referenced this issue Nov 28, 2022
It may return the same before and after state.
@spacemeowx2 spacemeowx2 linked a pull request Nov 28, 2022 that will close this issue
spacemeowx2 added a commit that referenced this issue Nov 28, 2022
It may return the same before and after state.
@spacemeowx2
Copy link
Owner

spacemeowx2 commented Nov 28, 2022

It should be fixed, could you try again with latest version? Please re-open this issue if not fixed.

@tako774
Copy link
Author

tako774 commented Nov 29, 2022

Thank you for your quick response.
I tried deno run -Ar https://raw.githubusercontent.com/spacemeowx2/s3si.ts/main/s3si.ts, though it was not fixed yet.

I found reporting to stat.ink succeeded with s3si.ts version 0.1.31.
So I tested by past commits and found af95def causing this problem.

My test process:

  1. clone this repository
  2. git checkout af95defd9aae82a0f7eeefa209cb9e90aaf2554d
  3. deno run -Ar ./s3si.ts/s3si.ts -e file
  4. rename export folder
  5. git checkout 707d7204dc7849ad8f60af89d7af627e67c533d5 (0.1.31)
  6. deno run -Ar ./s3si.ts/s3si.ts -e file
  7. diff exported files

Then Rank-Up Battle rankState content changed.

@tako774
Copy link
Author

tako774 commented Nov 29, 2022

@spacemeowx2
I'm not able to reopen (because not closing myself), so I tell by mention.

@spacemeowx2 spacemeowx2 reopened this Nov 29, 2022
@spacemeowx2
Copy link
Owner

spacemeowx2 commented Nov 29, 2022

I may need to explain the reason for this issue.

s3si.ts has a RankTracker module. When you don't manually enter a Rank, it will initialize your rankPoint when it finds the first successful promotion and save it in profile.json for later upload.

Before version 0.1.32, this module had some problems working. It would start uploading rankPoint after a program run, not immediately after a successful promotion.

When I fixed it in 0.1.32 I introduced another bug, which had actually appeared in RankTracker before, so I fixed that bug.

However, I haven't succeeded in promotion recently (3 consecutive failures :(. so I couldn't find and fix the problem for now.


In the latest version, it is expected that the rankState is not the same as the version you can work with. As long as the rankPoint of the rankState in all json is not -1, this should fix the problem. Since -1 is just a placeholder, it should not be uploaded to stat.ink

@tako774
Copy link
Author

tako774 commented Nov 29, 2022

I think I got it. Thanks for your explanation.

So one of workaround is maybe...

  • report the battles which contain Rank-Up Battles with s3si.ts version 0.1.31
  • init rank with initRank.ts
  • report with the latest s3si.ts (expecting for the problem fixed by time of next Rank-Up Battle)

Is it right?

@spacemeowx2
Copy link
Owner

You are right.

@tako774
Copy link
Author

tako774 commented Nov 29, 2022

Thank you. I will do so that way.

@tako774
Copy link
Author

tako774 commented Dec 1, 2022

FYI

The stat.ink API checks rank_after_exp >= 0, but actually rank point can be minus value. So this check is strange.
By chance my rank point has been below 0 now ;( and reported to stat.ink, API error "Rank After Exp must be no less than 0." happend.

I reported this here.
fetus-hina/stat.ink#1155

If it is fixed, rank_after_exp -1 value report might happen no error by stat.ink.

@spacemeowx2
Copy link
Owner

spacemeowx2 commented Dec 1, 2022

Oops, I didn't even realize that negative rank_after_exp numbers were legal before. But I think the -1 generated by RankTracker is still a bug

@fetus-hina
Copy link

fetus-hina commented Dec 1, 2022

Stat.ink now accepts negative UDEMAE points (rank_*_exp). Thank you telling me.

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
3 participants