From f32915969c789e972823be6127bf23e6396fdf44 Mon Sep 17 00:00:00 2001 From: Howard Zhong Date: Fri, 5 Dec 2025 15:55:01 +0000 Subject: [PATCH 1/3] Get rid of deprecated capability names in API response --- server_structs/director.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server_structs/director.go b/server_structs/director.go index cdbd60c82..9d36d9bb2 100644 --- a/server_structs/director.go +++ b/server_structs/director.go @@ -51,13 +51,12 @@ type ( CredentialIssuer url.URL `json:"issuer"` } - // Note that the json are kept in uppercase for backward compatibility Capabilities struct { - PublicReads bool `json:"PublicRead"` - Reads bool `json:"Read"` - Writes bool `json:"Write"` - Listings bool `json:"Listing"` - DirectReads bool `json:"FallBackRead"` + PublicReads bool `json:"PublicReads"` + Reads bool `json:"Reads"` + Writes bool `json:"Writes"` + Listings bool `json:"Listings"` + DirectReads bool `json:"DirectReads"` } NamespaceAdV2 struct { From 0e2dc1d82c070bde04457ebb3288c56d492f6e0d Mon Sep 17 00:00:00 2001 From: Howard Zhong Date: Fri, 5 Dec 2025 17:04:10 +0000 Subject: [PATCH 2/3] Add a helper function and struct for capability name conversion - When an Origin/Cache running Pelican before v7.22.0, they are advertising with the old names. This commit converts them into the new ones --- server_structs/director.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/server_structs/director.go b/server_structs/director.go index 9d36d9bb2..0ccc6bdf2 100644 --- a/server_structs/director.go +++ b/server_structs/director.go @@ -59,6 +59,22 @@ type ( DirectReads bool `json:"DirectReads"` } + // Supports both old and new JSON field names + capabilitiesCompat struct { + // New field names + PublicReads bool `json:"PublicReads"` + Reads bool `json:"Reads"` + Writes bool `json:"Writes"` + Listings bool `json:"Listings"` + DirectReads bool `json:"DirectReads"` + // Old field names (for backward compatibility) + PublicRead bool `json:"PublicRead"` + Read bool `json:"Read"` + Write bool `json:"Write"` + Listing bool `json:"Listing"` + FallBackRead bool `json:"FallBackRead"` + } + NamespaceAdV2 struct { Caps Capabilities // Namespace capabilities should be considered independently of the origin’s capabilities. Path string `json:"path"` @@ -321,6 +337,24 @@ const ( // We chose -1 to avoid the default value (0) of the int64 type const IndefiniteEndTime int64 = -1 +// Custom JSON unmarshalling for Capabilities to support backward compatibility. +// Old field names from origins/caches running Pelican earlier than v7.22.0 will be converted to the new field names. +func (c *Capabilities) UnmarshalJSON(data []byte) error { + var compat capabilitiesCompat + if err := json.Unmarshal(data, &compat); err != nil { + return err + } + + // Use new field names if set, otherwise fall back to old field names + c.PublicReads = compat.PublicReads || compat.PublicRead + c.Reads = compat.Reads || compat.Read + c.Writes = compat.Writes || compat.Write + c.Listings = compat.Listings || compat.Listing + c.DirectReads = compat.DirectReads || compat.FallBackRead + + return nil +} + func (x XPelNs) GetName() string { return "X-Pelican-Namespace" } From 9bfc2183ddeb7c7811b92d9055bcb6347d147072 Mon Sep 17 00:00:00 2001 From: Howard Zhong Date: Fri, 5 Dec 2025 17:15:15 +0000 Subject: [PATCH 3/3] Simplify the capability names logic in webUI - Update the names in `Capabilities` interface - Conversion is done in backend, so the frontend doesn't need to map the old names to new ones --- web_ui/frontend/components/CapabilitiesDisplay.tsx | 12 +----------- web_ui/frontend/types.ts | 10 +++++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/web_ui/frontend/components/CapabilitiesDisplay.tsx b/web_ui/frontend/components/CapabilitiesDisplay.tsx index a575ab632..a36aeb6b1 100644 --- a/web_ui/frontend/components/CapabilitiesDisplay.tsx +++ b/web_ui/frontend/components/CapabilitiesDisplay.tsx @@ -54,9 +54,7 @@ export const CapabilitiesChip = ({ overflow: 'hidden', }} > - - {CAPABILITY_LABEL_MAP[name] || name} - + {name} {value ? : } @@ -74,11 +72,3 @@ export const CapabilityChipStyle = { border: '1px 1px solid black', backgroundColor: green[300], }; - -const CAPABILITY_LABEL_MAP: Record = { - PublicRead: 'PublicReads', - Read: 'Reads', - Write: 'Writes', - Listing: 'Listings', - FallBackRead: 'DirectReads', -}; diff --git a/web_ui/frontend/types.ts b/web_ui/frontend/types.ts index f8d093e45..294b82f09 100644 --- a/web_ui/frontend/types.ts +++ b/web_ui/frontend/types.ts @@ -1,9 +1,9 @@ export interface Capabilities { - PublicRead: boolean; - Read: boolean; - Write: boolean; - Listing: boolean; - FallBackRead: boolean; + PublicReads: boolean; + Reads: boolean; + Writes: boolean; + Listings: boolean; + DirectReads: boolean; } export interface TokenGeneration {