thedotmack/claude-mem · error

observation_reindex source_id must belong to project_id and

Error message

observation_reindex source_id must belong to project_id and team_id

What it means

Thrown by validateSource when sourceType is 'observation_reindex'. The code looks up an observations row by (id=sourceId, project_id, team_id); if none exists the source observation is not accessible in that project/team scope, so the reindex job cannot be created.

Source

Thrown at src/storage/postgres/generation-jobs.ts:287

      return;
    }

    if (input.sourceType === 'session_summary') {
      const sessionId = input.serverSessionId ?? input.sourceId;
      await assertSessionOwnership(this.client, sessionId, input.projectId, input.teamId);
      if (input.sourceId !== sessionId) {
        throw new Error('session_summary source_id must equal server_session_id');
      }
      return;
    }

    const observation = await queryOne<{ id: string }>(
      this.client,
      'SELECT id FROM observations WHERE id = $1 AND project_id = $2 AND team_id = $3',
      [input.sourceId, input.projectId, input.teamId]
    );
    if (!observation) {
      throw new Error('observation_reindex source_id must belong to project_id and team_id');
    }
    if (input.serverSessionId) {
      await assertSessionOwnership(this.client, input.serverSessionId, input.projectId, input.teamId);
    }
  }
}

export class PostgresObservationGenerationJobEventsRepository {
  constructor(private client: PostgresQueryable) {}

  async append(input: {
    id?: string;
    generationJobId: string;
    projectId: string;
    teamId: string;
    eventType: ObservationGenerationJobEventType;
    statusAfter: ObservationGenerationJobStatus;
    attempt?: number;

View on GitHub (pinned to d768ba3643)

Solutions

  1. Verify the observation exists in scope first: SELECT id FROM observations WHERE id=$1 AND project_id=$2 AND team_id=$3.
  2. Confirm you are using the correct projectId and teamId for that observation (cross-tenant id reuse).
  3. If the observation was deleted, recreate it or choose a different existing source.

Example fix

// before
await jobs.create({ sourceType:'observation_reindex', sourceId: maybeDeletedId, projectId, teamId, jobType });
// after
const obs = await observations.getByIdForScope({ id: sourceId, projectId, teamId });
if (!obs) throw new Error('source observation not found in scope');
await jobs.create({ sourceType:'observation_reindex', sourceId, projectId, teamId, jobType });
Defensive patterns

Strategy: validation

Validate before calling

const obs = await observations.getByIdForScope({ id: sourceId, projectId, teamId });
if (!obs) throw new Error(`observation ${sourceId} not found in project ${projectId}/team ${teamId}`);

Prevention

When it happens

Trigger: Calling repository.create() with sourceType:'observation_reindex' and a sourceId that is not a row in observations for the given project and team. Note: sourceType here is 'observation_reindex' in the job repo, which only allows three types; the observation must already exist.

Common situations: Reindexing an observation from the wrong project/team, using an observation id from another tenant, reindexing an observation that was deleted, or a typo/corrupted id after an export-import.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12). Data as JSON: /api/errors/4528765b56feaf0b. Report an issue: GitHub.