Skip to content

fix: use _workspace when given for gateway validate#1783

Merged
harshadixit12 merged 6 commits intomainfrom
fix/gateway-validate-succeeds-with-invalid-workspace
Oct 16, 2025
Merged

fix: use _workspace when given for gateway validate#1783
harshadixit12 merged 6 commits intomainfrom
fix/gateway-validate-succeeds-with-invalid-workspace

Conversation

@harshadixit12
Copy link
Contributor

@harshadixit12 harshadixit12 commented Oct 14, 2025

Fixes:

  1. Deck not treating _workspace tag in YAML in the same manner as --workspace flag #1753
  2. deck validate ignore the _workspace field of state file #1700

Root cause for both: gateway validate did not respect _workspace set in the state file. The validation ran against default workspace, and therefore was incorrect as it did not load the referenced entities and schemas correctly.
This led to unauthorised access of default workspace when user had permissions scoped to a different workspace as seen in #1753.

With this fix, the online validation runs against the workspace specified in state file (unless overridden using -w or --workspace.

@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.70%. Comparing base (1ef3e8f) to head (a5d25b3).

Files with missing lines Patch % Lines
cmd/gateway_validate.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1783      +/-   ##
==========================================
- Coverage   32.71%   32.70%   -0.02%     
==========================================
  Files          73       73              
  Lines        8112     8116       +4     
==========================================
  Hits         2654     2654              
- Misses       5292     5296       +4     
  Partials      166      166              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

expectedState: utils.KongRawState{
Upstreams: upstream,
Targets: target,
Targets: targetPost312,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errorString: "workspace doesn't exist: nonexistent",
},
{
name: "validate with non-default _workspace and default_lookup_tags",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would fail without the changes in gateway_validate.go

@harshadixit12 harshadixit12 marked this pull request as ready for review October 14, 2025 07:18
@harshadixit12
Copy link
Contributor Author

For #1753 - before (tries loading entity schema from default workspace and fails) and after (this fails while loading workspace - and does not proceed to loading entity schema)
Screenshot 2025-10-14 at 11 12 18 AM
Screenshot 2025-10-14 at 11 12 03 AM

@harshadixit12 harshadixit12 merged commit e5cb2e8 into main Oct 16, 2025
38 checks passed
@harshadixit12 harshadixit12 deleted the fix/gateway-validate-succeeds-with-invalid-workspace branch October 16, 2025 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants