fix(cropper): alias the queue's core domain to uc; show server error text

Saving failed with 400 'Unknown domain.' because queue items carry the
legacy domain 'core', which the old bot mapped to 'uc' for a2loft URLs —
my domain validation (added in the review pass) rejected it. The save now
applies the same alias before validating and forwarding.

Also: the client showed axios's generic 'Request failed with status code
400' because the catch destructured error.message; all cropper handlers now
prefer the server's response.data.message (errMessage helper), so the real
reason is visible.

Verified: save with a 'core' item forwards to /identity/uc/profile/picture;
a 400 shows 'Unknown domain.'; 46 tests.
This commit is contained in:
2026-10-01 10:35:02 +01:00
parent 001290a789
commit 645d3d2bc9
3 changed files with 56 additions and 12 deletions
+35
View File
@@ -511,3 +511,38 @@ test('picture fetches reject object keys outside the id-domains prefix', async (
await stop();
}
});
test('a queue domain of core is saved against the uc code (legacy alias)', async () => {
const legacy = JSON.stringify({
upload_id: 'up-core',
file_name: 'id-domains/uc/raw-pictures/x/img.jpg',
caption: '08068287222',
domain: 'core',
raw_file_id: 'raw-1',
});
const { base, a2loft, stop } = await boot({ queue: fakeQueue(legacy) });
try {
const cookies = await login(base);
const res = await fetch(`${base}/cropper/profile/picture?otp=778899`, {
method: 'POST',
headers: { cookie: cookies, 'content-type': 'application/json' },
body: JSON.stringify({
pictureDataUrl: 'data:image/jpeg;base64,QUJD',
phone: '08068287222',
requiresCleaning: false,
message: {
pop_receipt: 'pop-1',
message_id: 'm-1',
message: { upload_id: 'up-core', domain: 'core', agentDeviceHash: 'a' },
},
}),
});
const body = await res.json();
assert.equal(res.status, 200, JSON.stringify(body));
const save = a2loft.calls.find((c) => c.url.includes('/profile/picture'));
assert.equal(decodeURIComponent(new URL(save.url, 'http://x').pathname), '/identity/uc/profile/picture');
} finally {
await stop();
}
});