fix(server): remove storage not found defect fallback (#27287)
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect } from "bun:test"
|
||||
import { Effect, Layer } from "effect"
|
||||
import { HttpClient, HttpClientRequest, HttpRouter } from "effect/unstable/http"
|
||||
import { errorLayer } from "../../src/server/routes/instance/httpapi/middleware/error"
|
||||
import { NotFoundError } from "../../src/storage/storage"
|
||||
import { testEffect } from "../lib/effect"
|
||||
|
||||
const it = testEffect(Layer.mergeAll(NodeHttpServer.layerTest, NodeServices.layer))
|
||||
@@ -27,4 +28,23 @@ describe("HttpApi error middleware", () => {
|
||||
expect(JSON.stringify(body)).not.toContain("secret stack marker")
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("does not map storage not-found defects to 404", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* HttpRouter.add(
|
||||
"GET",
|
||||
"/missing",
|
||||
Effect.die(new NotFoundError({ message: "Resource not found: secret" })),
|
||||
).pipe(Layer.provide(errorLayer), HttpRouter.serve, Layer.build)
|
||||
|
||||
const response = yield* HttpClientRequest.get("/missing").pipe(HttpClient.execute)
|
||||
const body = yield* response.json
|
||||
|
||||
expect(response.status).toBe(500)
|
||||
expect(body).toEqual({
|
||||
name: "UnknownError",
|
||||
data: { message: "Unexpected server error. Check server logs for details." },
|
||||
})
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user