#22113·meshery

[Server] Single SMI-result lookup queries a table that is never migrated

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

Description

The local provider can list persisted SMI results, but fetching one result by ID fails because the single-result path queries a different, unmigrated table.

Current Behavior

WriteResult stores rows as SmiResultWithID in smi_result_with_ids. GetResult declares a plain SmiResult, causing GORM to query smi_results; that table is not part of the system migrations. A request to GET /api/smi/results/{id} therefore fails even for a row that was just stored.

Expected Behavior

The single-result lookup should query the same model/table used by writes and list operations, returning the persisted result for its ID.

Steps to Reproduce

  1. Auto-migrate the current system database models.
  2. Persist an SMI result with SMIResultsPersister.WriteResult.
  3. Call SMIResultsPersister.GetResult with that same ID.
  4. Observe the database error no such table: smi_results.

Evidence

$ go test ./server/models -run '^TestReproSMIGetResultReadsPersistedTable$' -count=1
SELECT * FROM `smi_results` ...
no such table: smi_results
GetResult could not read the row WriteResult persisted
FAIL

Root Cause

GetResult queries SmiResult, while WriteResult and the system migration use SmiResultWithID.

Affected Components

  • Meshery Server
  • SMI result persistence
  • GET /api/smi/results/{id}

Validation

Executed on master commit 5b75615243e92b088b4ebf6e7bff82d6f60e5462:

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

Result: deterministic failure against SQLite with the current migrations; the lookup selects from an unmigrated table.

Acceptance Criteria

  • GetResult queries the same persisted model/table as WriteResult and GetResults.
  • A just-written result is retrievable by ID.
  • The returned JSON preserves the expected SMI result shape.
  • A regression test covers write-then-get.

References