Address review feedback: Scaffold FastAPI backend project structure #15
Closed
coder-bot
wants to merge 0 commits from
agent/521ef1e83a39 into main
pull from: agent/521ef1e83a39
merge into: daddy:main
daddy:main
daddy:agent/5a68d35804c7-pc4-packaging
daddy:agent/2b4212c24690-pc4-checkpoint
daddy:agent/b77bddf31ba5-godot-discover-home-ui
daddy:agent/56c49440d0a6-godot-discovery-client
daddy:agent/33706f401ad9-discovery-trending-sort
daddy:agent/300da1dcddf3-discovery-browse-search
daddy:agent/42726e60fe10-world-visit-tracking
daddy:agent/b377353b8167-world-discovery-metadata
daddy:agent/96e5f11d7896-godot-selling-payout-ui
daddy:agent/9797a0cfd9e6-godot-marketplace-ui
daddy:agent/34c725431645-godot-wallet-ui
daddy:agent/cc09c1428892-godot-economy-api-client
daddy:agent/4ba24a178c1b-marketplace-moderation-agegate
daddy:agent/b52008923e93-payout-review-audit
daddy:agent/f5b4684f2e65-payout-requests-api
daddy:agent/bc90d3f481b4-purchase-escrow-service
daddy:agent/8aaf7c48d376-reports
daddy:agent/5645c26acd5c-public-profile
daddy:agent/d6b3f928e9ad-dm-chat
daddy:agent/86f6ef19b352-profile-model
daddy:agent/8bc166bd983b-friends-router
daddy:agent/cc677e477fe8-groups-api
daddy:agent/4daac3f1cfba-text-filter
daddy:agent/ff065522ba55-group-models
daddy:agent/9eaf37ab424c-rate-limit-dep
daddy:agent/9e1b957d4ba4-chat-models
daddy:agent/f039e52c4b44-social-graph-models
daddy:agent/dd2a126b57a1-presence-recovery
daddy:agent/da6e9f0ae7db-editor-save-persist
daddy:agent/8f1c523a192c-editor-mvp
daddy:agent/0fcbdba8ad02-client-persistence-plumbing
daddy:agent/b34cc0769dd4-world-persistence-backend
daddy:agent/6882fd1336fe-scripting-dsl
daddy:agent/64d9aef16e02-world-persistence-design
daddy:agent/9e7930c1b631
daddy:agent/896fbb97de1d
daddy:agent/48206289ff51
daddy:agent/806cbbff5213
daddy:agent/3bba30f838d1
daddy:agent/9bfb90314053
daddy:agent/0c49a36fc7db
daddy:agent/82015c078037
daddy:agent/b35fdc80cbe7
daddy:agent/a6deeb84eace
daddy:agent/f32370ab515a
daddy:agent/9186405a6373
daddy:agent/470f875e0416
daddy:agent/28357bca192d
daddy:agent/f4c371c981ba
daddy:agent/8ba2e727a079
daddy:agent/0b9e2c5ae6ec
daddy:agent/398bf1a22a2d
daddy:docs/pc1-checkpoint-record
daddy:agent/775379a9bedc
daddy:agent/1de295a0da42
daddy:agent/daf820da4497
daddy:agent/82c3ebd03921
daddy:agent/1bc0bc15886d
daddy:fix/pin-bcrypt-version
daddy:agent/424ce35e1b38
daddy:agent/a7d462fe1322
daddy:docs/test-inventory-and-runner
daddy:agent/d90bce564f55
daddy:agent/a547fd649f4c
daddy:agent/5b3da417b50c
daddy:agent/a755410a1c91
daddy:agent/76aa20cd2e45
daddy:agent/8705247aee3b
daddy:agent/5db523f4ee96
daddy:agent/19af79688cec
daddy:agent/ff065522ba55
daddy:agent/21694e349045
daddy:agent/25d5046bb30c
daddy:agent/101dc4b5b50a
daddy:fix/migration-0001-double-enum-and-port-collision
daddy:agent/3f3f21813946
daddy:agent/eb7dcb48c5d9
daddy:agent/189033f31353
daddy:agent/0969b759803d
daddy:agent/bc240b6723f6
daddy:agent/c88fc6092439
daddy:agent/cf1b515ab412
daddy:agent/55088d5301d4
daddy:agent/b377353b8167
daddy:agent/a048e11b2c2a
daddy:agent/10066a449585
daddy:agent/dd2a126b57a1
daddy:agent/8343bc0a730f
daddy:agent/f039e52c4b44
daddy:agent/9eaf37ab424c
daddy:agent/7fedeb122f7e
daddy:agent/4daac3f1cfba
daddy:agent/f96c351dfa5e
daddy:agent/9e1b957d4ba4
daddy:agent/bd718b31b595
daddy:agent/5b8c6bf79631
daddy:pr-review
daddy:agent/6be8efe94fab
daddy:agent/8f93a0732163
daddy:agent/1a6e82153969
daddy:agent/684f458e47fc
daddy:agent/b03f366f5538
daddy:agent/ecd7c0ce8744
daddy:agent/7ab353cfd1ac
daddy:agent/ec0074121ca3
daddy:agent/e8de6a8ddb00
daddy:agent/c92c939b819c
daddy:agent/identitytest111
daddy:agent/997c429bc6b4
daddy:agent/a6930697b17d
daddy:agent/4f174a207618
daddy:agent/fa0834ec1ba7
daddy:agent/1cfe9ef94f55
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "agent/521ef1e83a39"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Auto-opened by coder for task
521ef1e83a39.Dashboard: http://cloudbison:7070/task/521ef1e83a39
Reviewer requested changes on PR #1 for this task.
Feedback:
The scaffold is well-structured and the code parses cleanly, but there are several serious security issues that must be fixed before this can merge. This is a foundation PR that other work will build on, so these need to be right now.
Critical security issues
backend/app/routers/users.py— PATCH/DELETE/GET have NO authentication and NO ownership checks.PATCH /api/users/{user_id},DELETE /api/users/{user_id}, andGET /api/users/{user_id}take onlydb: Depends(get_db)— noCurrentUserdependency and no ownership verification. Any anonymous caller can delete any user, change any user's email or deactivate them, or enumerate all users' data. These endpoints needcurrent_user: CurrentUserplus an ownership check (e.g.if user.id != current_user.id: 403), or admin-only authorization.backend/app/routers/worlds.py—GET /api/worlds/andGET /api/worlds/{id}have no auth and leak private data. They return worlds regardless ofvisibility, so a user'sPRIVATE/FRIENDS_ONLYworlds are exposed to anyone. These need auth and a visibility/ownership filter.backend/app/routers/assets.pyline 162 —upload_asset_filedeclarescurrent_user: CurrentUser = None, making the auth dependency optional. For unauthenticated requestscurrent_userisNoneandcurrent_user.idraisesAttributeError→ 500. It should becurrent_user: CurrentUser(no default), consistent with the other asset endpoints.Moderate issues
backend/app/database.py—get_dbunconditionally callsawait session.commit()after every request, including read-only GETs, and it's redundant with the explicitdb.commit()calls in the handlers. This double-commit pattern is error-prone. Prefer aget_dbthat only yields the session and lets handlers manage their own transactions (or remove the explicit commits).worlds.pyusesworld_data: dictwith no Pydantic schema.WorldVisibility(world_data.get("visibility", "public"))raisesValueError→ 500 on any invalid string, and arbitrary keys are silently accepted. Use a proper Pydantic model with a validated enum field.users.pycreate_userduplicatesauth.pyregister— two ways to create a user with inconsistent behavior (one returns a token, the other returns the user). Consolidate.users.pyGET /meis a 501 placeholder — dead endpoint that should be removed or implemented (and noteauth.pyalready provides/api/auth/me).assets.pyupload_asset_file—file.filenameis used unsanitized in the stored path (uploads/{asset_id}_{file.filename}), a path-traversal risk if this is later used to write files;file_sizeis hardcoded to 0; and no actual file write happens (TODO). At minimum sanitize the filename and validate size againstMAX_UPLOAD_SIZE_MB.dependencies.pyget_current_user—int(user_id)can raiseValueError→ 500 ifsubisn't an integer; wrap it so a malformed token yields 401.assets.pyAssetResponseuses deprecatedclass Config: from_attributes = Trueinstead ofmodel_config = {"from_attributes": True}used elsewhere — inconsistent and will warn on pydantic v2.auth.pylogin expects a JSON body butOAuth2PasswordBearer(tokenUrl="/api/auth/login")implies form-encoded OAuth2 — the Swagger "Authorize" flow won't work against this endpoint. Either useOAuth2PasswordRequestFormor a bearer scheme that matches.config.pySECRET_KEYdefault is"change-me-to-a-secure-random-string"— acceptable for a scaffold since.env.exampleexists, but worth a comment that production must override it.The structure, models, migration, docker-compose, and env template are solid and the migration matches the models. Please address the three critical security issues (and ideally the moderate ones) and I'll re-review.
PR: daddy/agp-game#1
Branch: agent/ec0074121ca3
Original task description:
Create the Python backend project under backend/:
Commit to git.
I reviewed the full diff against the previous review feedback. The code parses cleanly and the structure/migration/docker-compose are solid, but the three critical security issues from the previous review are still completely unaddressed, and most moderate issues remain. This PR is titled "Address review feedback" but does not actually fix the security problems.
Critical — still NOT fixed
users.py— PATCH/DELETE/GET have NO auth and NO ownership checks.get_user,update_user, anddelete_userstill take onlydb: Depends(get_db). Any anonymous caller can delete any user, change any user's email/deactivate them, or enumerate all users' data. These needcurrent_user: CurrentUserplus an ownership check (e.g.if user.id != current_user.id: 403), or admin-only authorization.worlds.py—GET /andGET /{id}have no auth and leak private data.list_worldsandget_worldstill return worlds regardless ofvisibility. A user'sPRIVATE/FRIENDS_ONLYworlds are exposed to anyone. These need auth and a visibility/ownership filter.assets.py—upload_asset_filestill declarescurrent_user: CurrentUser = None. For unauthenticated requestscurrent_userisNoneandcurrent_user.idraisesAttributeError→ 500. It should becurrent_user: CurrentUser(no default), consistent with the other asset endpoints.Moderate — mostly still NOT fixed
database.pyget_db— FIXED (no longer unconditionally commits; handlers manage their own transactions). Good.worlds.pystill usesworld_data: dictwith no Pydantic schema;WorldVisibility(...)still raisesValueError→ 500 on invalid strings.users.pycreate_userstill duplicatesauth.pyregister.users.pyGET /meis still a 501 placeholder.assets.pyupload_asset_filestill uses unsanitizedfile.filenamein the path, hardcodesfile_size = 0, and has no actual file write.dependencies.pyget_current_userstill doesint(user_id)outside the try block →ValueError→ 500 on malformedsub.assets.pyAssetResponsestill uses deprecatedclass Config: from_attributes = Trueinstead ofmodel_config.auth.pylogin still expects a JSON body whileOAuth2PasswordBearer(tokenUrl="/api/auth/login")implies form-encoded OAuth2 — Swagger "Authorize" won't work.config.pySECRET_KEY default — acceptable for scaffold (.env.exampleexists).Since this is a foundation PR that other work will build on, the three critical security issues (anonymous user deletion/data enumeration, private world leakage, and the 500-on-upload bug) must be fixed before merge. Please address them and I'll re-review.
Superseded by #17, which addressed the requested changes and merged. Closing.
Pull request closed