Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuang-Minh Nguyen <qmnguyen@gitlab.com>2022-12-20 19:10:24 +0300
committerQuang-Minh Nguyen <qmnguyen@gitlab.com>2022-12-20 19:10:24 +0300
commit054801f8842ad423579022062922d223652a06ae (patch)
tree65cbcd67c73d0a0314de0cf31236523813d292f7
parent2bc64b5e1f449aadb2de37d2b70ebdf5c954c799 (diff)
parent85c9c0efa10f31f2e14800b8feec1a877c0c0235 (diff)
Merge branch 'pks-tree-entry-structured-error-metadata' into 'master'
commit: Don't put tree entry name into error message See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5200 Merged-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Approved-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Reviewed-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
-rw-r--r--internal/gitaly/service/commit/tree_entry.go2
-rw-r--r--internal/gitaly/service/commit/tree_entry_test.go6
2 files changed, 4 insertions, 4 deletions
diff --git a/internal/gitaly/service/commit/tree_entry.go b/internal/gitaly/service/commit/tree_entry.go
index ae6c34f3f..3d43d0ddb 100644
--- a/internal/gitaly/service/commit/tree_entry.go
+++ b/internal/gitaly/service/commit/tree_entry.go
@@ -28,7 +28,7 @@ func sendTreeEntry(
}
if treeEntry == nil || len(treeEntry.Oid) == 0 {
- return structerr.NewNotFound("not found: %s", path)
+ return structerr.NewNotFound("tree entry not found").WithMetadata("path", path)
}
if treeEntry.Type == gitalypb.TreeEntry_COMMIT {
diff --git a/internal/gitaly/service/commit/tree_entry_test.go b/internal/gitaly/service/commit/tree_entry_test.go
index 30a74f90b..781f1cd1b 100644
--- a/internal/gitaly/service/commit/tree_entry_test.go
+++ b/internal/gitaly/service/commit/tree_entry_test.go
@@ -214,17 +214,17 @@ func TestFailedTreeEntry(t *testing.T) {
{
name: "Path is outside of repository",
req: &gitalypb.TreeEntryRequest{Repository: repo, Revision: []byte("913c66a37b4a45b9769037c55c2d238bd0942d2e"), Path: []byte("../bar/.gitkeep")}, // Git blows up on paths like this
- expectedErr: structerr.NewNotFound("not found: ../bar/.gitkeep"),
+ expectedErr: structerr.NewNotFound("tree entry not found"),
},
{
name: "Missing file with space in path",
req: &gitalypb.TreeEntryRequest{Repository: repo, Revision: []byte("deadfacedeadfacedeadfacedeadfacedeadface"), Path: []byte("with space/README.md")},
- expectedErr: structerr.NewNotFound("not found: with space/README.md"),
+ expectedErr: structerr.NewNotFound("tree entry not found"),
},
{
name: "Missing file",
req: &gitalypb.TreeEntryRequest{Repository: repo, Revision: []byte("e63f41fe459e62e1228fcef60d7189127aeba95a"), Path: []byte("missing.rb")},
- expectedErr: structerr.NewNotFound("not found: missing.rb"),
+ expectedErr: structerr.NewNotFound("tree entry not found"),
},
} {
t.Run(tc.name, func(t *testing.T) {