Skip to content

feat: add method to validate feature toggles - #284

Open
NicoleMGomes wants to merge 3 commits into
mainfrom
feat/feature-toggle
Open

feat: add method to validate feature toggles#284
NicoleMGomes wants to merge 3 commits into
mainfrom
feat/feature-toggle

Conversation

@NicoleMGomes

Copy link
Copy Markdown
Contributor

Disclaimer: Do not include SAP-internal or customer-specific information in this PR (e.g. internal system URLs, customer names, tenant IDs, or confidential configurations). This is a public repository.

Description

Adds feature toggle support to the runtime context module. DWCContextProvider now reads the dwc-feature-toggles request header (a comma-separated list of active toggle names) and stores it under the new FEATURE_TOGGLES context key. A new top-level helper is_feature_enabled(name) checks whether a named toggle is active for the current request, returning False when the header is absent or the toggle is not listed.

The implementation follows the same pattern as DWC_SUBDOMAIN / DWC_TENANT extraction in DWCContextProvider.

Related Issue

Closes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

  1. Bootstrap an application with bootstrap(app) (uses DWCContextProvider by default).
  2. Send a request with header dwc-feature-toggles: my-feature,other-feature.
  3. Inside a request handler, call is_feature_enabled("my-feature") — expect True.
  4. Call is_feature_enabled("absent-feature") — expect False.
  5. Send a request without the header; both calls return False.
  6. Run unit tests: pytest tests/core/unit/runtime_context/ -v — all 45 tests pass.

Checklist

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have updated documentation (if applicable)
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

Additional Notes

  • FEATURE_TOGGLES is exported from sap_cloud_sdk.core.runtime_context alongside the existing DWC keys.
  • is_feature_enabled is also exported at the same level for ergonomic use in request handlers.
  • Whitespace around individual toggle names in the header value is trimmed.

@NicoleMGomes
NicoleMGomes marked this pull request as ready for review August 25, 2026 18:40
@NicoleMGomes
NicoleMGomes requested a review from a team as a code owner August 25, 2026 18: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.

1 participant