diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md index 564d5e117..c19d7da8e 100644 --- a/server/CHANGELOG.md +++ b/server/CHANGELOG.md @@ -45,6 +45,7 @@ not generally be shown to end users. - [ENH] Server administrators can now revert other's imports. - [ENH] You can now set Jubility targets. - [ENH] Folder Showcase Stats are now removed from a player in the case of the folder being removed. +- [ENH] ARC SDVX Support has been bumped to EXCEED GEAR. - [INTERNAL_ENH] Server version info is now read from package.json, removing redundancy. - [INTERNAL_ENH] The commit the server is running under is now exposed publically in version info. # 2.1.18 diff --git a/server/src/lib/score-import/import-types/api/arc-sdvx/parser.test.ts b/server/src/lib/score-import/import-types/api/arc-sdvx/parser.test.ts index 387bff9e5..85cf412dd 100644 --- a/server/src/lib/score-import/import-types/api/arc-sdvx/parser.test.ts +++ b/server/src/lib/score-import/import-types/api/arc-sdvx/parser.test.ts @@ -11,13 +11,13 @@ const logger = CreateLogCtx(__filename); t.test("#ParseArcSDVX", (t) => { t.beforeEach(ResetDBState); const mockArcAPI = MockJSONFetch({ - "https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile": { + "https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile": { _links: { - _next: "https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile&page=2", + _next: "https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile&page=2", }, _items: [1, 2, 3], }, - "https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile&page=2": { + "https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile&page=2": { _links: { _next: null, }, diff --git a/server/src/lib/score-import/import-types/api/arc-sdvx/parser.ts b/server/src/lib/score-import/import-types/api/arc-sdvx/parser.ts index 93bd7f8f0..0d2acf469 100644 --- a/server/src/lib/score-import/import-types/api/arc-sdvx/parser.ts +++ b/server/src/lib/score-import/import-types/api/arc-sdvx/parser.ts @@ -24,9 +24,9 @@ export async function ParseArcSDVX( iterable: TraverseKaiAPI( ServerConfig.ARC_API_URL, - // VIVID WAVE. + // EXCEED GEAR. // The trailing slash is critical! ARC only allows /? queries. - `/api/v1/sdvx/5/player_bests/?profile_id=${authDoc.accountID}`, + `/api/v1/sdvx/6/player_bests/?profile_id=${authDoc.accountID}`, ServerConfig.ARC_AUTH_TOKEN, logger, null, diff --git a/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts b/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts index e3698ad85..16fc63605 100644 --- a/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts +++ b/server/src/lib/score-import/import-types/common/api-kai/traverse-api.ts @@ -112,13 +112,19 @@ export async function* TraverseKaiAPI( continue; } + let text; + try { + // Split this into text -> JSON parse so we can read the text for better error messages + // in the case of disaster. // eslint-disable-next-line no-await-in-loop - json = (await res.json()) as unknown; + text = await res.text(); + + json = JSON.parse(text) as unknown; } catch (err) { logger.error( `Received invalid (non-json) response from ${url}. Status code was ${res.status}.`, - { err } + { err, text } ); throw new ScoreImportFatalError( 500, diff --git a/server/src/test-utils/mock-fetch.ts b/server/src/test-utils/mock-fetch.ts index 6c5e883b8..076e29fac 100644 --- a/server/src/test-utils/mock-fetch.ts +++ b/server/src/test-utils/mock-fetch.ts @@ -20,6 +20,7 @@ export function MockJSONFetch(urlDataMap: Record) { if (url in urlDataMap) { const fakeResponse = { status: 200, + text: () => Promise.resolve(JSON.stringify(urlDataMap[url])), json: () => Promise.resolve(urlDataMap[url]), } as unknown as Response;