Unistore: Change to 404 rather than 403 if not found (#103743)

This commit is contained in:
Stephanie Hingtgen
2025-04-09 19:14:39 -05:00
committed by GitHub
parent 870d401f75
commit 68ed0feeff
2 changed files with 11 additions and 1 deletions
+3
View File
@@ -654,6 +654,9 @@ func (s *server) Read(ctx context.Context, req *ReadRequest) (*ReadResponse, err
}
rsp := s.backend.ReadResource(ctx, req)
if rsp.Error != nil && rsp.Error.Code == http.StatusNotFound {
return &ReadResponse{Error: rsp.Error}, nil
}
a, err := s.access.Check(ctx, user, claims.CheckRequest{
Verb: "get",
+8 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
"testing"
"time"
@@ -94,6 +95,12 @@ func TestSimpleServer(t *testing.T) {
require.NoError(t, err)
require.Len(t, all.Items, 0)
// should return 404 if not found
found, err := server.Read(ctx, &ReadRequest{Key: key})
require.NoError(t, err)
require.NotNil(t, found.Error)
require.Equal(t, int32(http.StatusNotFound), found.Error.Code)
created, err := server.Create(ctx, &CreateRequest{
Value: raw,
Key: key,
@@ -103,7 +110,7 @@ func TestSimpleServer(t *testing.T) {
require.True(t, created.ResourceVersion > 0)
// The key does not include resource version
found, err := server.Read(ctx, &ReadRequest{Key: key})
found, err = server.Read(ctx, &ReadRequest{Key: key})
require.NoError(t, err)
require.Nil(t, found.Error)
require.Equal(t, created.ResourceVersion, found.ResourceVersion)