Description
The /satellites/{satellite}/images endpoint returns a 500 Internal Server Error.
Investigation
Adding a print statement to the handler reveals the underlying error from pq:
Root Cause
The error originates in GetLatestArtifacts. The query uses = ANY(subquery) where the subquery returns artifact_ids as an integer[] row value:
Querying artifact_ids directly shows the value is returned in array form {1,2} — PostgreSQL cannot apply = ANY(...) against this:
Fix
Replace = ANY(subquery) with IN (SELECT unnest(...)) to expand the array into individual scalar rows:
SELECT a.id, a.reference, a.size_bytes, a.created_at
FROM artifacts a
WHERE a.id IN (
SELECT unnest(artifact_ids) FROM (
SELECT artifact_ids FROM satellite_status
WHERE satellite_id = $1
ORDER BY created_at DESC LIMIT 1
) latest
)
ORDER BY a.reference

Description
The
/satellites/{satellite}/imagesendpoint returns a 500 Internal Server Error.Investigation
Adding a print statement to the handler reveals the underlying error from
pq:Root Cause
The error originates in
GetLatestArtifacts. The query uses= ANY(subquery)where the subquery returnsartifact_idsas aninteger[]row value:Querying
artifact_idsdirectly shows the value is returned in array form{1,2}— PostgreSQL cannot apply= ANY(...)against this:Fix
Replace
= ANY(subquery)withIN (SELECT unnest(...))to expand the array into individual scalar rows: