Add CI lint for hardcoded user_id and gate demo-sensitive routers via ALWRITY_DEMO_RELEASE#456
Open
Add CI lint for hardcoded user_id and gate demo-sensitive routers via ALWRITY_DEMO_RELEASE#456
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
user_id = 1,force user_id) outside of test fixtures by failing CI checks./api/routers/statuslisting.Description
.github/workflows/lint-forced-user-id.ymlthat runs a repository check on PRs and pushes tomainto detect forced/hardcodeduser_idpatterns.backend/scripts/check_forced_user_id_patterns.py, a script that scans python sources (while excluding tests/fixtures and the script itself) and fails on patterns like\buser_id\s*=\s*1\bandforce user_id.RouterManager(backend/alwrity_utils/router_manager.py) via a_demo_release_mode_enabled()helper that readsALWRITY_DEMO_RELEASEand skips inclusion offacebook_writer,linkedin,linkedin_image, andpersonarouters when enabled so they do not appear inincluded_routers.current_userand by replacing other forceduser_idoccurrences with eitherrequest-derived IDs or an environment-configurable fallback (ALWRITY_FALLBACK_USER_ID), and update monitoring/strategy services to resolve user IDs from DB records where appropriate.backend/sif_release_readiness_checks.pyto check the presence of the demo-release guard strings in the router manager source.Testing
python backend/scripts/check_forced_user_id_patterns.pywhich reported no violations after the code updates (passed).python -m py_compileagainst the modified modules to validate syntax (passed).PYTHONPATH=backend python -m unittest backend/sif_release_readiness_checks.py, which exercises the added source check, but the run reported a pre-existing unrelated test error (ContentGuardianAgentmissingverify_originality) that caused the suite to fail and is not caused by these changes.pull_requestandpushtomainso the repository will block merges that reintroduce forbidden patterns.Codex Task