@@ -78,6 +78,24 @@ func mockPodLoadServer(t *testing.T, respondOK bool) *httptest.Server {
7878 return srv
7979}
8080
81+ // mockPodNotFoundServer mimics the emulator response when the requested cloud
82+ // snapshot does not exist: the platform version lookup fails, so the load
83+ // completes with the generic "Failed to get version information" diagnostic.
84+ func mockPodNotFoundServer (t * testing.T ) * httptest.Server {
85+ t .Helper ()
86+ srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
87+ if strings .HasPrefix (r .URL .Path , "/_localstack/pods/" ) && r .Method == http .MethodPut {
88+ w .Header ().Set ("Content-Type" , "application/x-ndjson" )
89+ w .WriteHeader (http .StatusOK )
90+ _ , _ = w .Write ([]byte (`{"event":"completion","status":"error","message":"Failed to get version information from platform.. aborting"}` + "\n " ))
91+ return
92+ }
93+ w .WriteHeader (http .StatusNotFound )
94+ }))
95+ t .Cleanup (srv .Close )
96+ return srv
97+ }
98+
8199// writeTestSnapFile creates a small file usable as a local snapshot source.
82100func writeTestSnapFile (t * testing.T , dir , name string ) string {
83101 t .Helper ()
@@ -294,6 +312,32 @@ func TestSnapshotLoadPodServerError(t *testing.T) {
294312 assert .Contains (t , stderr , "platform unavailable" )
295313}
296314
315+ // TestSnapshotLoadPodNotFound covers a non-existent cloud snapshot. The emulator
316+ // cannot fetch version information for an unknown pod and reports the generic
317+ // platform diagnostic; lstk must translate it into a clear "not found" message
318+ // rather than leaking "Failed to get version information from platform".
319+ func TestSnapshotLoadPodNotFound (t * testing.T ) {
320+ requireDocker (t )
321+ cleanup ()
322+ t .Cleanup (cleanup )
323+
324+ ctx := testContext (t )
325+ startTestContainer (t , ctx )
326+ srv := mockPodNotFoundServer (t )
327+
328+ stdout , stderr , err := runLstk (t , ctx , t .TempDir (),
329+ env .Environ (testEnvWithHome (t .TempDir (), "" )).
330+ With (env .LocalStackHost , lsHost (srv )).
331+ With (env .AuthToken , "test-token" ),
332+ "--non-interactive" , "snapshot" , "load" , "pod:does-not-exist" ,
333+ )
334+ requireExitCode (t , 1 , err )
335+ // The user-facing error is emitted through the sink (stdout); the raw
336+ // platform diagnostic must not leak to the user.
337+ assert .Contains (t , stdout , "not found on the LocalStack platform" )
338+ assert .NotContains (t , strings .ToLower (stdout + stderr ), "version information" )
339+ }
340+
297341func TestSnapshotLoadTelemetryEmitted (t * testing.T ) {
298342 requireDocker (t )
299343 cleanup ()
0 commit comments