thedotmack/claude-mem · error
internal_error
Error message
internal_error
What it means
The compat observations adapter wraps ingestion in a try/catch and responds with HTTP 500 { stored:false, reason:'internal_error' } for any unexpected failure while translating the legacy payload into a Server beta agent_event and delegating to IngestEventsService. It is a generic catch-all; the real cause is only in the server logs under 'compat observations adapter failed'.
Solutions
- Check server logs for the 'compat observations adapter failed' entry to find the underlying exception
- Retry the request after confirming the database is reachable and migrations are current
- Inspect the legacy payload for unexpected nulls (contentSessionId etc.) and fix the client
- Add explicit handling/mapping for the underlying error class in the adapter
Example fix
// server log
// before: { stored:false, reason:'internal_error' } with no clue
// after: logger.error includes error.stack and parsed payload for diagnosis
logger.error('SYSTEM', 'compat observations adapter failed', { error: err.message, stack: err.stack, payload: parsed.data }); Defensive patterns
Strategy: retry
Validate before calling
// client-side pre-check
if (!payload.contentSessionId) throw new Error('contentSessionId is required before ingest'); Type guard
const hasSessionId = (p) => typeof p?.contentSessionId === 'string' && p.contentSessionId.length > 0;
Try / catch
// client: retry transient 500s, surface persistent ones
if (res.status === 500 && body.reason === 'internal_error') {
if (attempt < 3) return retryWithBackoff(attempt + 1);
throw new Error(`Ingest failed persistently: ${await res.text()}`);
} Prevention
- Monitor server logs for 'compat observations adapter failed' with alerting
- Keep database migrations current before deploying the server
- Include error.stack in the adapter's log payload for faster diagnosis
- Add integration tests covering the legacy payload -> agent_event translation
When it happens
Trigger: Any exception thrown inside ingestCompatObservation — e.g. database write failure, IngestEventsService rejection, schema/tenant lookup error — after the payload has passed validation.
Common situations: Database outage or migration drift when inserting the agent_event row; null/undefined fields in the legacy payload that hit unexpected code paths; bugs introduced during compat-layer refactors.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/75eb10cd8e92e17d.
Report an issue: GitHub.
Appendix: source
Thrown at src/server/compat/SessionsObservationsAdapter.ts:94
if (!projectId) {
// Compat mode requires a project-scoped key — the legacy payload does
// not carry a Server beta projectId, so without scope we cannot place
// the row in a tenant-scoped table.
res.status(400).json({
error: 'BadRequest',
message: 'Legacy /api/sessions/observations requires a project-scoped API key',
});
return;
}
try {
await this.ingestCompatObservation(req, res, parsed.data, teamId, projectId);
} catch (error) {
logger.error('SYSTEM', 'compat observations adapter failed', {
error: error instanceof Error ? error.message : String(error),
contentSessionId: parsed.data.contentSessionId,
});
res.status(500).json({ stored: false, reason: 'internal_error' });
}
}));
}
// Body of the legacy observations route — translates the legacy payload
// into a Server beta agent_event and delegates to IngestEventsService.
private async ingestCompatObservation(
req: Request,
res: Response,
data: z.infer<typeof observationsSchema>,
teamId: string,
projectId: string,
): Promise<void> {
const platformSource = normalizePlatformSource(
typeof data.platformSource === 'string'
? data.platformSource
: DEFAULT_PLATFORM_SOURCE,
);View on GitHub (pinned to d8bc9755e7)