Skip to content

Commit c4295bc

Browse files
fix: resolve workspace name before PATCH masking_rule
The policy API uses the resource string as an exact-match filter, so "workspaces/-" does not resolve to the current workspace for policy endpoints (only GetWorkspace has dash-expansion). Without this, the PATCH silently creates an orphan policy with resource="workspaces/-" instead of updating the real workspace policy. Fetch the real workspace name via GET /workspaces/- first, then use it in the PATCH URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a0ab5db commit c4295bc

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/1-bb-masking-semantic-type-global.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,17 @@ jobs:
106106
id: apply-global-masking-rule
107107
if: ${{ steps.changed-files.outputs.any_changed == 'true' && contains(steps.changed-files.outputs.all_changed_files, 'global-masking-rule.json') }}
108108
run: |
109-
CHANGED_FILE="masking/global-masking-rule.json"
109+
CHANGED_FILE="masking/global-masking-rule.json"
110110
echo "Processing: $CHANGED_FILE"
111-
112-
response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/workspaces/-/policies/masking_rule?allowMissing=true&updateMask=payload" \
111+
112+
# Resolve the current workspace resource name. Policy URLs need the
113+
# real workspace ID — "workspaces/-" only works for GetWorkspace.
114+
WORKSPACE_NAME=$(curl -s \
115+
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
116+
"${{ steps.bytebase-login.outputs.api_url }}/workspaces/-" | jq -r '.name')
117+
echo "Workspace: $WORKSPACE_NAME"
118+
119+
response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/${WORKSPACE_NAME}/policies/masking_rule?allowMissing=true&updateMask=payload" \
113120
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
114121
--header "Content-Type: application/json" \
115122
--data @"$CHANGED_FILE")

.github/workflows/3-bb-masking-classification.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,17 @@ jobs:
8888
id: apply-global-masking-rule
8989
if: ${{ steps.changed-files.outputs.any_changed == 'true' && contains(steps.changed-files.outputs.all_changed_files, 'global-masking-rule-classification.json') }}
9090
run: |
91-
CHANGED_FILE="masking/global-masking-rule-classification.json"
91+
CHANGED_FILE="masking/global-masking-rule-classification.json"
9292
echo "Processing: $CHANGED_FILE"
93-
94-
response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/workspaces/-/policies/masking_rule?allowMissing=true&updateMask=payload" \
93+
94+
# Resolve the current workspace resource name. Policy URLs need the
95+
# real workspace ID — "workspaces/-" only works for GetWorkspace.
96+
WORKSPACE_NAME=$(curl -s \
97+
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
98+
"${{ steps.bytebase-login.outputs.api_url }}/workspaces/-" | jq -r '.name')
99+
echo "Workspace: $WORKSPACE_NAME"
100+
101+
response=$(curl -s -w "\n%{http_code}" --request PATCH "${{ steps.bytebase-login.outputs.api_url }}/${WORKSPACE_NAME}/policies/masking_rule?allowMissing=true&updateMask=payload" \
95102
--header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
96103
--header "Content-Type: application/json" \
97104
--data @"$CHANGED_FILE")

0 commit comments

Comments
 (0)