Skip to content

Conversation

@Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented Dec 18, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Closes #168

This PR upgrades the flagsmith-flag-engine from v6.1.0 to v10.0.3 following the approach from flagsmith-python-client#150, and implements the hide_disabled_flags project setting.

Changes

Engine Migration (v6 → v10)

  • Upgraded flagsmith-flag-engine from 6.1.0 to 10.0.3
  • Added flagsmith>=5 dependency for TypedDict models and mappers
  • Migrated from Pydantic models to TypedDict-based evaluation contexts
  • Replaced deprecated engine functions with new get_evaluation_result()
  • Used map_environment_document_to_context() and map_context_and_identity_data_to_context() from flagsmith-python-client
  • Updated traits handling from list[TraitModel] to dict[str, ContextValue] with backward compatibility validator
  • Updated response mappers to work with new flag result format

hide_disabled_flags

  • Added filter_disabled_flags() helper
  • Implemented filtering in src/edge_proxy/environments.py for both /api/v1/flags/ and /api/v1/identities/ endpoints
  • Only applies to client keys (server keys bypass this filter)
  • Single feature requests return 404 if the feature is disabled and hide_disabled_flags == true

Tests

  • Added new tests in tests/test_server.py for hide_disabled_flags functionality
  • Added test fixture environment_with_hide_disabled_flags in tests/fixtures/response_data.py

How did you test this code?


Local Integration Testing:
1. Start edge proxy: rye run edge-proxy-serve
2. Test with Node.js SDK pointing to http://localhost:8000/api/v1/
3. Verify responses with hide_disabled_flags both enabled and disabled:

# Get all flags
curl -s -L -H "X-Environment-Key: ser.xxx" \
  http://localhost:8000/api/v1/flags/ | jq

# Get identity flags
curl -s -L -X POST \
  -H "X-Environment-Key: ser.xxx" \
  -H "Content-Type: application/json" \
  -d '{"identifier": "test-user"}' \
  http://localhost:8000/api/v1/identities/ | jq

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner December 18, 2025 11:22
@Zaimwa9 Zaimwa9 requested review from emyller and removed request for a team December 18, 2025 11:22
assert response.status_code == 401


def test_get_flags__client_key__hide_disabled_flags_enabled__only_returns_enabled_flags(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented hide_disabled_flags only for client keys. It's ambiguous in Project settings and it does mention that it's to hide the flags from end users.
Let me know if needs to do it for server keys too

@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for emyller December 24, 2025 10:08
) -> dict[str, Any] | None:
return self._environment_cache.get(environment_api_key)

def get_identity(
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 doesn't seem to be necessary anymore but would appreciate confirmation:

  • this was used to have a cache access to server-side identity overrides
  • engine now handles these overrides via the environment document
  • it keeps the proxy stateless

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.

Context Values: Engine V7 compatibility

2 participants