From 95544b65ef2bdba5b65d8165e7173e37b381d56d Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Wed, 1 Jul 2026 11:59:47 +0200 Subject: [PATCH] docs(graph): drop stale regex references from colon-path comments The colon-syntax parsing is plain string operations now, but a few comments still referred to "the previous regex" / "captures". Update them to match: parseColonPath extracts the itemID from the path (driveID comes from the route param), and the shape checks stand on their own. --- services/graph/pkg/middleware/path_lookup.go | 15 +++++++-------- services/graph/pkg/middleware/path_lookup_test.go | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/services/graph/pkg/middleware/path_lookup.go b/services/graph/pkg/middleware/path_lookup.go index 43bb25f174..7ddb0cc7c8 100644 --- a/services/graph/pkg/middleware/path_lookup.go +++ b/services/graph/pkg/middleware/path_lookup.go @@ -140,7 +140,7 @@ func ResolveGraphPath(gws pool.Selectable[gateway.GatewayAPIClient], logger log. // substrings from RoutePath; rewriteColonPath decodes them as needed. type colonMatch struct { isItemAnchored bool // item-anchored form: anchor is itemAnchorID, validate against driveID - itemAnchorID string // captured itemID for the item-anchored form (empty for root-anchored) + itemAnchorID string // itemID from the path for the item-anchored form (empty for root-anchored) relPath string // relative path with leading slash suffix string // suffix with leading slash (e.g. "/children"); may be empty } @@ -193,10 +193,10 @@ func rewriteColonPath( return "", errInvalidRequest } - // Item-anchored form captures driveID and itemID separately. Validate the - // itemID belongs to the given driveID (storage + space prefix) - otherwise - // the request is malformed and we short-circuit instead of doing an - // unnecessary CS3 Stat. + // Item-anchored form: the itemID comes from the path, driveID from the + // route param. Validate the itemID belongs to the given driveID (storage + + // space prefix) - otherwise the request is malformed and we short-circuit + // instead of doing an unnecessary CS3 Stat. if match.isItemAnchored { drive, err := storagespace.ParseID(driveID) if err != nil { @@ -282,9 +282,8 @@ func parseColonPath(routePath string) (colonMatch, bool) { rest = strings.TrimSuffix(rest, ":") m.relPath, m.suffix, _ = strings.Cut(rest, ":") - // Shape requirements (matching the previous regex): the path must be - // absolute and non-empty ("/x"), and a present suffix must be absolute and - // colon-free. + // Shape requirements: the path must be absolute and non-empty ("/x"), and a + // present suffix must be absolute and colon-free. if len(m.relPath) < 2 || m.relPath[0] != '/' { return m, false } diff --git a/services/graph/pkg/middleware/path_lookup_test.go b/services/graph/pkg/middleware/path_lookup_test.go index b933c81a9d..9347862c03 100644 --- a/services/graph/pkg/middleware/path_lookup_test.go +++ b/services/graph/pkg/middleware/path_lookup_test.go @@ -204,8 +204,8 @@ func TestResolveGraphPath(t *testing.T) { }, { // Multi-segment suffix: /permissions/{permissionID}/setPassword on - // v1beta1 (POST). Pins that the suffix regex carries embedded slashes - // through the rewrite into a real nested route. + // v1beta1 (POST). Pins that parseColonPath carries a suffix with + // embedded slashes through the rewrite into a real nested route. name: "v1beta1 root-anchored with multi-segment suffix rewrites and routes", method: http.MethodPost, urlPath: "/graph/v1beta1/drives/" + testDriveID + "/root:/folder1:/permissions/perm-1/setPassword",