#22110·meshery

[Server] Performance-result lookup returns an unrelated row for an unknown ID

Author: maverickaayushCreated Sep 27, 2026Updated Sep 28, 2026

Description

GET /api/perf/profile/result/{id} can return an unrelated stored performance result when the requested ID does not exist. The lookup executes before the ID predicate is attached, so the first row wins.

Current Behavior

Looking up a random, absent result ID returns the first row in meshery_results with a nil error.

Expected Behavior

The result lookup must apply the requested ID before executing and return a not-found error when no matching result exists.

Steps to Reproduce

  1. Create an in-memory database and migrate MesheryResult.
  2. Persist one result with MesheryResultsPersister.WriteResult.
  3. Call MesheryResultsPersister.GetResult with a different UUID.
  4. Observe that the stored result is returned.

Evidence

A minimal in-package regression test fails deterministically:

$ go test ./server/models -run '^TestReproMesheryResultLookupAppliesIDFilter$' -count=1
lookup for absent id <absent-id> returned stored result <stored-id> ("stored")
FAIL

The user-facing route calls this persister through GetResultHandler.

Root Cause

MesheryResultsPersister.GetResult calls Find(&lres) before .Where("id = ?", key). In GORM, Find executes the query; the subsequent Where only mutates a new statement after the result has already been loaded.

Affected Components

  • Meshery Server
  • Performance result persistence
  • GET /api/perf/profile/result/{id}

Validation

Executed on master commit 5b75615243e92b088b4ebf6e7bff82d6f60e5462:

go test ./server/models -run '^TestReproMesheryResultLookupAppliesIDFilter$' -count=1

Result: reproducible failure on every run; an absent ID returns the existing row.

Acceptance Criteria

  • The ID predicate is applied before the query executes.
  • An unknown result ID does not return any other stored result.
  • A regression test covers both matching and absent IDs.

References