Skip to content

fix(users): preserve omitted next plans in partial updates - #998

Merged
T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-omitted-user-next-plan
Oct 11, 2026
Merged

T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-omitted-user-next-plan

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A note-only user update currently deletes an existing next plan because an omitted next_plan defaults to None. Update or remove the plan only when that field was explicitly supplied. Template application explicitly supplies next_plan=None to preserve its existing replacement behavior.

Type of change

  • Bug fix

Testing

  • 102 local checks passed: the existing tests/api/test_user.py suite plus regressions for note-only API/CRUD edits, explicit null, replacement, and template arguments.
  • Ruff on both changed files and git diff --check passed.

Notes for reviewers

Only two production Python files change. Regression scripts remain local; no test or documentation files, migrations, or dependency changes are included.

Combined validation of all four independent audit fixes: the patches applied together without conflicts, and 232 local tests passed on a fresh SQLite database.

Summary by CodeRabbit

  • Bug Fixes
    • Updating a user without specifying a scheduled plan now preserves the existing plan.
    • When a user update explicitly supplies an empty plan—including through a user template—the existing scheduled plan is cleared. This makes it possible to distinguish between leaving a plan unchanged and intentionally removing it.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91da32d6-b386-4774-a185-48ebc46d1ba2

📥 Commits

Reviewing files that changed from the base of the PR and between 0c869b0 and 3a6a6d1.


📒 Files selected for processing (2)
  • app/db/crud/user.py
  • app/operation/user.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



Walkthrough

Template-derived user arguments now include next_plan: None. User modification changes the plan only when next_plan is supplied: a value creates or replaces the plan, and an explicit null deletes it.

Changes

Next Plan Updates

Layer / File(s) Summary
Template arguments and update behavior
app/operation/user.py, app/db/crud/user.py
Template-derived arguments now include next_plan: None. User modification checks whether next_plan was supplied before creating, replacing, or deleting a plan.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: m03ed

Merge Risk: ⚪ Minimal · up to 3a6a6

Note-only updates retain an existing next plan, while explicit null and template updates can still remove it. No material merge-blocking risk is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving omitted next plans during partial user updates.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the plan with care
An absent field leaves plans there
A value sets the plan anew
An explicit null removes it too
The carrot ledger marks it through

Comment @coderabbitai help to get the list of available commands.

@dr-hoseyn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@T3ST3ST3R0N
T3ST3ST3R0N merged commit 3ec5635 into PasarGuard:dev Oct 11, 2026
10 checks passed
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
…a3d2d2fe2

Checked with git ls-remote on 2026-10-12 15:36 UTC; panel main and every
tag and release are unchanged.

Panel dev, six commits after 0c869b0:
- fd5e95e (PasarGuard#997, passkey challenge consumed by one conditional DELETE,
  configured RP ID honoured), 92acbae (subscription pages escaped,
  markup rejected in host addresses) and 0c9b1e5 (PasarGuard#1001, an unknown
  admin filter no longer falls back to global statistics) are queued
  security: yes, each with the fork lines it affects and its fixer:
  PG-UP-PASSKEY997, PG-UP-SUBESC and PG-UP-STATS1001.
- 3ec5635 (PasarGuard#998, an omitted next_plan no longer deletes the user's next
  plan) is queued security: no until 2026-10-19 as billing data loss.
- 63f9915 and 79f04fe (Xray WireGuard inbound validation and its lint
  suppressions) are queued security: no with PasarGuard#996.
- 785c5f2 is recorded as ported by design: its pick bd264a6 is whole,
  and the one removed line the pick check now flags is the fork's
  select-then-delete in _consume_challenge, which fd5e95e replaces.
- The masque branch moved to fa5dfc2 (359c8cf MASQUE settings and a
  merge of dev); both are unmerged work, waived while unmerged.
- The 1c25036 entry now names all three remaining
  dangerouslySetInnerHTML uses, including terminal-line.tsx:66.
- The chart and HWID queue lines name their porting branches.

Node dev, two commits after e03754dec: PasarGuard#101 (a3d2d2fe2, forward accept
rules kept out of mangle chains) is queued security: no until 2026-10-19
for both the WireGuard and the L2TP copy of ensureNFTForwarding, and PasarGuard#102
(36dc7a4a7, removes .gitlab-ci.yml) is already true of the fork.

Against live upstream the panel gate fails only on the 22 port-queue
commits classified security: yes, and the forks gate only on node
f72ac0efacdb.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
…eferences

- 785c5f2: names its cherry-pick bd264a6
  in full. At upstream dev 9e68477 the pick check compares 30 of its 37
  hunks and misses none, so the gate counts it by that trailer; the old
  sentence that the check flags a line since 79f04fe is gone. The skipped
  _authorize_target_admin hunk's admins.passkeys check was checked by hand.
- e6ca015: names 1c20204 in full, and
  the pointer to the emSign distrust names no file paths, so the design check
  reads the cite in pyproject.toml and uv.lock, which is what it claims.
- e538dc1: names the reworded commits 4a77aed84 and 59cbdbaaa that
  fix/port-1053-format-fields carries; 2452f27c4 and b76794943 are only on
  backup/port-1053-pre-reword-20261030.
- PasarGuard#998: cites app/db/crud/user.py:1270-1279 on 3b10bde, which includes the
  await db.delete(db_user.next_plan) line.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants