mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(wanderer): log why an answer from wanderer was not understood
A failed wanderer call kept its reason in WandererError.detail (the field that did not match, or what came instead of JSON), and the client comment said it stays in the log, but nothing wrote it anywhere. The log only had the generic 'wanderer answered with something TREK does not understand', so neither an admin nor we could tell what wanderer had sent. Every refusal now logs its code, message and detail.
This commit is contained in:
@@ -2,6 +2,7 @@ import { WandererConnections } from '../../db/entities/WandererConnections.entit
|
||||
import type { WandererConnectionsRepository } from '../../db/repositories/WandererConnections.repository';
|
||||
import { decodePolyline, thinLine } from '../../utils/polyline';
|
||||
import { checkSsrf } from '../../utils/ssrfGuard';
|
||||
import { logWarn } from '../audit/audit-log.logger';
|
||||
import { AuditService } from '../audit/audit.service';
|
||||
import { decrypt_api_key, maybe_encrypt_api_key } from '../common/crypto/apiKeyCrypto';
|
||||
import { DomainError } from '../common/domain-error';
|
||||
@@ -183,9 +184,14 @@ export class WandererService {
|
||||
await this.connections.recordCheck(userId, ok, code);
|
||||
}
|
||||
|
||||
/** A failed call, with a rejected token noted on the connection so its card says so. */
|
||||
/**
|
||||
* A failed call, with a rejected token noted on the connection so its card
|
||||
* says so. The log gets the reason the client is not shown: which field of
|
||||
* wanderer's answer did not match, or what came instead of JSON.
|
||||
*/
|
||||
private async failed(userId: number, err: unknown): Promise<never> {
|
||||
if (!(err instanceof WandererError)) throw err;
|
||||
logWarn(`[wanderer] ${err.code}: ${err.message}${err.detail ? ` (${err.detail})` : ''}`);
|
||||
if (err.code === 'unauthorized') await this.noteCheck(userId, false, err.code);
|
||||
throw refusalOf(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user