Summary
staging-livepeer-api is logging an error every hour when trying to update the lastSeen timestamp for a specific API token. The error indicates that the token ID is being passed as undefined to the DB update query, causing the api_token record lookup to fail.
Error Details
Service: staging-livepeer-api
Time window: 2026-03-29 18:09 UTC – 2026-03-30 06:09 UTC
Total occurrences: 18 (roughly every 30-60 mins, clustered around the :31 minute mark of each hour)
Token ID: 2f25c979-904f-4fce-b329-4174b54fdcbf
Error message
error saving last seen: table=api_token id=2f25c979-904f-4fce-b329-4174b54fdcbf err= Ge [Error]: api_token id=undefined not found
Surrounding context (from Loki)
The same token 2f25c979-904f-4fce-b329-4174b54fdcbf is being successfully used for DB SELECTs and UPDATEs in other queries (e.g. UPDATE api_token SET data = data || ... WHERE id = '2f25c979...' rows=1), but some code path is calling saveLastSeen() with id=undefined instead of the resolved ID. The error message format id=<real-uuid> err=...: api_token id=undefined not found suggests the UUID is logged correctly at the call site, but the DB query receives undefined.
Occurrence timestamps (UTC)
2026-03-29 19:31:42 UTC
2026-03-29 20:31:39 UTC
2026-03-29 21:31:37 UTC
2026-03-29 21:31:48 UTC
2026-03-29 22:31:37 UTC
2026-03-29 22:31:42 UTC
2026-03-29 22:31:48 UTC
2026-03-29 22:31:52 UTC
2026-03-29 23:00:00 UTC (approx)
2026-03-30 00:31:37 UTC
2026-03-30 00:31:45 UTC
2026-03-30 00:31:52 UTC
2026-03-30 01:31:45 UTC
2026-03-30 02:31:48 UTC
2026-03-30 03:31:48 UTC
2026-03-30 04:31:45 UTC
2026-03-30 04:31:51 UTC
2026-03-30 05:31:39 UTC
2026-03-30 05:31:48 UTC
Likely Cause
The saveLastSeen function (or caller) in staging-livepeer-api is receiving the API token object but dereferencing the ID field incorrectly — e.g. token.id returns undefined when the field is named differently (e.g. token.userId, token.tokenId), or a race condition causes the token object to be undefined when the async callback fires.
The real UUID is logged in the error context (id=2f25c979-904f-4fce-b329-4174b54fdcbf), suggesting it's available at the log-writing level but not passed correctly into the DB query.
Impact
- Staging only (no indication in prod Loki)
lastSeen timestamps for this API token are not being updated
- Token remains functional for auth (SELECT queries succeed)
- ~18 spurious error log entries per 12h window
Suggested Fix
Search for the saveLastSeen function in staging-livepeer-api and check:
- The field name used to extract the token ID (might be
id vs. tokenId vs. another field)
- Whether the token object could be
undefined or re-shaped before being passed to saveLastSeen
Loki Query
{app="staging-livepeer-api"} |~ "api_token id=undefined"
Detected automatically by scope-monitor cron at 2026-03-30 06:09 UTC
Summary
staging-livepeer-apiis logging an error every hour when trying to update thelastSeentimestamp for a specific API token. The error indicates that the token ID is being passed asundefinedto the DB update query, causing theapi_tokenrecord lookup to fail.Error Details
Service:
staging-livepeer-apiTime window: 2026-03-29 18:09 UTC – 2026-03-30 06:09 UTC
Total occurrences: 18 (roughly every 30-60 mins, clustered around the :31 minute mark of each hour)
Token ID:
2f25c979-904f-4fce-b329-4174b54fdcbfError message
Surrounding context (from Loki)
The same token
2f25c979-904f-4fce-b329-4174b54fdcbfis being successfully used for DB SELECTs and UPDATEs in other queries (e.g.UPDATE api_token SET data = data || ... WHERE id = '2f25c979...'rows=1), but some code path is callingsaveLastSeen()withid=undefinedinstead of the resolved ID. The error message formatid=<real-uuid> err=...: api_token id=undefined not foundsuggests the UUID is logged correctly at the call site, but the DB query receivesundefined.Occurrence timestamps (UTC)
Likely Cause
The
saveLastSeenfunction (or caller) instaging-livepeer-apiis receiving the API token object but dereferencing the ID field incorrectly — e.g.token.idreturnsundefinedwhen the field is named differently (e.g.token.userId,token.tokenId), or a race condition causes the token object to beundefinedwhen the async callback fires.The real UUID is logged in the error context (
id=2f25c979-904f-4fce-b329-4174b54fdcbf), suggesting it's available at the log-writing level but not passed correctly into the DB query.Impact
lastSeentimestamps for this API token are not being updatedSuggested Fix
Search for the
saveLastSeenfunction instaging-livepeer-apiand check:idvs.tokenIdvs. another field)undefinedor re-shaped before being passed tosaveLastSeenLoki Query
Detected automatically by scope-monitor cron at 2026-03-30 06:09 UTC