Skip to content

[bug]: Ground Control endpoint /satellites/{satellite}/images returns 500 #366

@NucleoFusion

Description

@NucleoFusion

Description

The /satellites/{satellite}/images endpoint returns a 500 Internal Server Error.

Image

Investigation

Adding a print statement to the handler reveals the underlying error from pq:

Image

Root Cause

The error originates in GetLatestArtifacts. The query uses = ANY(subquery) where the subquery returns artifact_ids as an integer[] row value:

Image

Querying artifact_ids directly shows the value is returned in array form {1,2} — PostgreSQL cannot apply = ANY(...) against this:

Image

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
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions