Repository navigation
refactor(handlers): extract createManagedCatalog handler into admin_catalog_operations - #839
Merged
Merged
Conversation
…atalog_operations Slice 3 of the #773 admin_operations split: move the managed-catalog creation concern (the createManagedCatalog handler plus its private validation/build/persist helpers) from admin_operations into its own module src/handlers/admin_catalog_operations.py, with zero behavior change. - The seven functions (_parse_product_price, _validate_and_process_product, _validate_catalog_input, _build_catalog_item, _persist_catalog, _require_admin_and_get_actor_sub, create_managed_catalog) move verbatim; the only textual difference is the file-boundary newline, because create_managed_catalog is now the module's last function. - This is the cleanest of the three extractions: every private helper it uses, including _require_admin_and_get_actor_sub, is used only by the createManagedCatalog handler, so the whole concern travels to the new module with no function-level import from admin_operations at all. - The dispatcher map in admin_operations stays the single registry: it imports create_managed_catalog back at module load (safe — the new module imports nothing from this module), and the AppSync handler mapping plus the Lambda entry point are unchanged. No IaC change: the Lambda payload ships the whole src/ tree. - admin_operations drops its now-unused `import uuid` and the `Decimal`/`InvalidOperation` imports. - Tests: the create_managed_catalog import in test_admin_operations.py is repointed to the new module, and the two `tables` patch targets in TestCreateManagedCatalog follow the code to src.handlers.admin_catalog_operations; no test logic changed. Verified: uv run pytest tests/unit -q (1841 passed, 2 skipped, 100% coverage), ruff check src/ tests/, ruff format --check src/, mypy src/ (strict), xenon A/B complexity gate, cspell on the changed files, and tofu validate (dev).
… admin_user_deletion Slice 4 of the #773 admin_operations split: move the per-entity user deletion concern (the four adminDeleteUser* handlers plus their shared profile-sweep helper) from admin_operations into its own module src/handlers/admin_user_deletion.py, with zero behavior change. - The five functions (_user_profiles_for, admin_delete_user_orders, admin_delete_user_campaigns, admin_delete_user_shares, admin_delete_user_profiles) move byte-identical; the only textual difference is the function-level import of _require_admin_and_get_target_account_id from .admin_operations in each handler (same convention as admin_account_purge, since a top-level import would be circular). - admin_operations keeps the dispatcher as the single registry (it imports the four handlers back at module load) and drops the four delete_user_* names from its .deletion_cascade import. The AppSync mapping and the Lambda entry point are unchanged; no IaC change (the payload ships the whole src/ tree). - Line counts: src/handlers/admin_operations.py 839 -> 775; src/handlers/admin_user_deletion.py 123 (new). Tests: - tests/unit/test_admin_operations.py: repoint the 21 function-local imports of the four handlers from src.handlers.admin_operations to src.handlers.admin_user_deletion; no test logic and no patch target changed (the suites mock src.handlers.deletion_cascade.tables / src.handlers.campaign_operations.tables, which stay put). - Full unit suite green (1841 passed, 2 skipped, 100% coverage), ruff check src/ tests/ + ruff format --check src/, mypy src/ (strict), xenon A/B complexity gate, cspell on the changed files, and tofu validate (dev).
…tial reset handlers Slice 5 of the #773 admin_operations split: move the remaining read and update handlers (the account-scoped adminGetUser* reads, the profile-share and campaign shared-code mutations, and adminResetUserPassword) from admin_operations into their own modules, with zero behavior change. - The 24 functions move byte-identical; the only textual difference is the in-function import of the shared helpers (_require_admin_and_get_target_account_id / _actor_sub) from .admin_operations in the 8 handlers that need them, the same convention admin_account_purge / admin_user_deletion already use (a top-level import would be circular). - Three new modules: - admin_user_reads.py: adminGetUser{Profiles,Catalogs,Campaigns, SharedCampaigns} plus the campaign-catalog batch helpers. - admin_share_campaign_ops.py: adminGetProfileShares, adminDeleteShare, adminUpdateCampaignSharedCode plus their helpers. - admin_credential_reset.py: adminResetUserPassword plus its helpers. - admin_operations keeps the dispatcher as the single registry (it imports the eight handlers back at module load) and drops the 24 moved functions and the now-unused imports. The AppSync mapping and the Lambda entry point are unchanged; no IaC change (the Lambda package ships the whole src/ tree). - Line counts: admin_operations.py 775 -> 271; admin_user_reads.py 287 (new), admin_share_campaign_ops.py 247 (new), admin_credential_reset.py 126 (new). Tests: - tests/unit/test_admin_operations.py: 34 function-local patch/import targets repointed off src.handlers.admin_operations (16 to admin_credential_reset, 11 to admin_user_reads, 6 to admin_share_campaign_ops, and 1 to deletion_cascade.tables where that handler reads its tables, the base's admin_operations.tables patch there being a no-op), plus the module-level handler/helper imports; no test logic changed. - tests/unit/test_cognito_filter_call_sites.py: the _find_user_by_email row now points at admin_credential_reset. - Full unit suite green (1841 passed, 2 skipped, 100% coverage), ruff check src/ tests/ + ruff format --check, mypy src/ (strict), xenon A/B complexity gate. No IaC or frontend change.
dmeiser
force-pushed
the
fm/KW-ISSUE-773-SHIP-3
branch
from
October 26, 2026 23:12
aa95323 to
011bcac
Compare
The _parse_product_price function was missing the check for non-finite values (Infinity, NaN) which caused tests to fail with INTERNAL_ERROR instead of INVALID_INPUT.
This branch was successfully deployed
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.
Slice 3 of the
admin_operationssplit (#773): extract thecreateManagedCatalogconcern into a newsrc/handlers/admin_catalog_operations.py. Issue #773 stays open — still inadmin_operationsareadminResetUserPassword, theadminDeleteUser*/adminGetUser*per-entity handlers,adminDeleteShare,adminUpdateCampaignSharedCode, and the dispatcher.What changed
_parse_product_price,_validate_and_process_product,_validate_catalog_input,_build_catalog_item,_persist_catalog,_require_admin_and_get_actor_sub,create_managed_catalog) move byte-identical (the only textual difference is the file-boundary newline —create_managed_catalogis now the module's last function)._require_admin_and_get_actor_sub, is used only by thecreateManagedCataloghandler, so the new module imports nothing fromadmin_operations.admin_operationskeeps the dispatcher as the single registry (it importscreate_managed_catalogback at module load) and drops its now-unusedimport uuidandDecimal/InvalidOperation. The AppSync mapping and the Lambda entry point are unchanged; no IaC change (the payload ships the wholesrc/tree).src/handlers/admin_operations.py987 → 839;src/handlers/admin_catalog_operations.py194 (new).Tests
tests/unit/test_admin_operations.py: repoint thecreate_managed_catalogimport and the twotablespatch targets inTestCreateManagedCatalogtosrc.handlers.admin_catalog_operations; no test logic changed.ruff check src/ tests/+ruff format --check src/,mypy src/(strict), xenon A/B complexity gate, cspell on the changed files, andtofu validate(dev).