Skip to content

Prevent startup permission initialization from re-granting legacy collection access#7992

Open
acwhite211 wants to merge 3 commits intov7_12_0_4from
key-migration-fixes
Open

Prevent startup permission initialization from re-granting legacy collection access#7992
acwhite211 wants to merge 3 commits intov7_12_0_4from
key-migration-fixes

Conversation

@acwhite211
Copy link
Copy Markdown
Member

Summary

This change stops the startup run_key_migration_functions path from re-importing legacy SP6 collection access into SP7 permissions. Because the startup path re-ran the full initializer, users with legacy SP6 principal rows could regain /system/sp7/collection access on startup, even if that SP7 access had been intentionally removed.

Made running the key migrations function optional at startup with RUN_KEY_MIGRATION_ON_STARTUP=0 in the .env file. Also fixed the warning of null tasks from happening in the key migration logs.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list

@acwhite211 acwhite211 added this to the 7.12.1 milestone Apr 17, 2026
@github-project-automation github-project-automation bot moved this to 📋Back Log in General Tester Board Apr 17, 2026
@acwhite211 acwhite211 changed the base branch from main to v7_12_0_4 April 17, 2026 22:32
@acwhite211 acwhite211 marked this pull request as ready for review April 17, 2026 22:32
Copy link
Copy Markdown
Contributor

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

Generally looks good! Nice work 💯

@app.task(bind=True, max_retries=SCHEMA_DEFAULTS_MISSING_DISCIPLINE_MAX_RETRIES)
def apply_schema_defaults_task(self, discipline_id: int):
"""Run schema localization defaults for one discipline in a background worker."""
task_id = getattr(self.request, 'id', None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(pretty optional)

Right now I see we're calling this function using the run method?

apply_schema_defaults_task.run(discipline.id)

I see the Celery docs reccommend using apply to run tasks synchronously/locally:
https://docs.celeryq.dev/en/latest/reference/celery.app.task.html#celery.app.task.Task.apply

I'm not entirely sure what run does, but I'm assuming apply boils down to run. run generally states:

When called tasks apply the run() method. This method must be defined by all tasks (that is unless the call() method is overridden).
Run
The body of the task executed by workers.

https://docs.celeryq.dev/en/latest/reference/celery.app.task.html#celery.app.task.Task.run

Perhaps we can be more in-line with what Celery expects by instead using apply here. I'm not sure what the tradeoffs are for going with the current approach over apply, but it seems to run the function anyway, so not too big of a deal.

Copy link
Copy Markdown
Contributor

@melton-jason melton-jason left a comment

Choose a reason for hiding this comment

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

Actually, I don't think we can/should disable the run_key_migration_functions by default in the v7.12.0.4 release, unfortunately.

There's a lot of deduplication functionality in the run_key_migration_functions in the release that resolve regressions.

We could make an argument for keeping run_key_migration_functions disabled by default, but that would require everyone who had updated to v7.12.0.0-v7.12.0.3 to intentionally re-enable the function and set the environment variable as part of their update process...

@grantfitzsimmons @acwhite211
What are your thoughts on this?

@github-project-automation github-project-automation bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Apr 18, 2026
@grantfitzsimmons
Copy link
Copy Markdown
Member

@melton-jason I say we keep it enabled for now and discuss for 7.12.1.

@melton-jason
Copy link
Copy Markdown
Contributor

I brought these changes except for the disabling of run_key_migration_functions into another branch/PR that I brought to v7.12.0.4: #7995

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

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

3 participants