Skip to content

Bug fix: Apply the app group lifecycle plugin when creating an app - #796

Open
barborico wants to merge 1 commit into
mainfrom
brynna/app_create_lifecycle_plugin
Open

barborico wants to merge 1 commit into
mainfrom
brynna/app_create_lifecycle_plugin

Conversation

@barborico

@barborico barborico commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

POST /api/apps now saves app_group_lifecycle_plugin and plugin_data, validating the config against the chosen plugin and keeping plugin config Access-admin-only, as PUT does. PUT /api/apps/{id} also now rejects a newly assigned plugin id that no registered plugin claims when the body carries no plugin_data.

Urgency: one week
Expected review effort: 5 min

Motivation

CreateAppBody accepts both plugin fields, but the create route ignored them, so an app could only get its plugin through a follow-up PUT. The app create form already sends both fields for Access admins, so their config was silently dropped. Fixing this lets app requests (#748) set a plugin on creation the same way the direct path does.

Validation

Confidence: high

  • New tests for POST /api/apps: valid plugin and config (response, stored row, group_created for the owner group, and both fields in the app_create audit event); invalid config → 400; unknown plugin id with and without plugin_data → 400; neither field → unchanged behavior; non-admin app creator → 403 with plugin fields, 201 without.
  • New tests for PUT /api/apps/{id}: assigning an unregistered plugin id alone → 400; re-sending an unchanged, unregistered stored id → 200.
  • Confirmed the new tests fail without the fix (except the neither-field case, which matches current behavior).

Risks

None known. Requests that omit both fields behave as before.

Guidance for Reviewers

  • Validation lives in CreateApp, using the lower-level validate_app_group_lifecycle_plugin_app_config. The *_or_raise helper raises HTTPException, which operations avoid. Like ApproveGroupRequest, the operation raises ValueError or AppGroupLifecyclePluginFilteringError, and the route maps them to 400 or 500, as the group request routes do.
  • Plugins now hear about an app's initial groups. The app has its plugin before the owner group and any initial app groups are created, so the plugin gets group_created for them.
  • Create and PUT differ when only the plugin id is sent. Create also checks the plugin's config, so a plugin with required config fails without plugin_data. PUT only checks that the id is registered. Applying the config check on PUT would reject plugin assignments that are allowed today.
  • PUT checks only a changed id. The edit form re-sends the stored id on every save, so an app whose plugin was removed from the deployment stays editable.

🤖 Generated with Claude Code

POST /api/apps accepted app_group_lifecycle_plugin and plugin_data in
CreateAppBody but dropped them, so an app could only get its plugin
through a follow-up PUT. The app create form already sends both fields
for Access admins, so their configuration was silently lost.

CreateApp now takes both fields. Before writing anything, it validates
plugin_data against the chosen plugin's app-level configuration. It
checks whenever a plugin is chosen, so an unknown plugin id is rejected
even without plugin_data. It then sets both fields on the app, which
also puts them in the app_create audit event. The owner group and any
initial app groups are created under an app that already has the
plugin, so the plugin gets group_created for them.

The route maps the operation's errors the same way the group request
routes do: a ValueError becomes a 400, and a filtering error becomes a
400 for an unknown plugin id or a 500 for a misbehaving plugin. Plugin
config stays Access-admin-only, as on PUT. An app creator who isn't an
admin gets a 403 when supplying either field but can still create an
app without them.

PUT /api/apps/{id} validated only when the body carried plugin_data,
so it accepted a new, unregistered plugin id sent on its own. It now
rejects that with a 400. A stored id that is re-sent unchanged is left
alone, because the edit form sends it on every save and an app whose
plugin was dropped from the deployment must stay editable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@barborico barborico mentioned this pull request Nov 25, 2026
2 tasks
@barborico barborico changed the title Apply the app group lifecycle plugin when creating an app Bug fix: Apply the app group lifecycle plugin when creating an app Nov 25, 2026
@barborico
barborico marked this pull request as ready for review November 25, 2026 02:50
@barborico
barborico enabled auto-merge (squash) November 25, 2026 02:50

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI review

No findings.
Reviewed commit b703f041c169f4c87c7d7b62c155a91b7bc48713.

Where reviewers should focus

  • api/routers/apps.py: Adds the Access-admin gate on plugin fields at app creation, and a new check on PUT that rejects a changed plugin id no registered plugin claims.
  • api/operations/create_app.py: Validates and saves the lifecycle plugin and plugin_data before the owner and initial groups are created, so those groups now trigger the plugin's group_created hook.

Risk areas: risk:auth, risk:async-orm, risk:plugin-api, risk:audit.

Findings

No issue met the reporting bar.

Blockers above fail this check. Push a fix to run the review again.

Automated review. A maintainer still reviews every pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant