Skip to content

fix(admin): allow clearing data limit with null - #804

Open
dr-hoseyn wants to merge 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-admin-null-data-limit
Open

fix(admin): allow clearing data limit with null#804
dr-hoseyn wants to merge 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-admin-null-data-limit

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • Distinguish an omitted data_limit from an explicit null in admin updates.
  • Clear the persisted limit when API clients send {"data_limit": null} while preserving the existing 0 behavior.
  • Add API regression coverage for omitted, zero, and explicit-null updates.

Fixes #802

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Documentation
  • Tests / CI

Checklist

  • I tested the change locally or explained why it cannot be tested.
  • I added or updated tests for behavior changes.
  • I updated documentation, translations, or examples if needed.
  • I checked database migrations when models or schema changed.
  • I did not include secrets, tokens, private keys, or unrelated changes.

Testing

python -m pytest tests/api/test_admin.py::test_admin_data_limit_set_and_returned tests/api/test_admin.py::test_admin_data_limit_zero_means_unlimited tests/api/test_admin.py::test_admin_data_limit_null_means_unlimited -q
3 passed

python -m ruff check app/db/crud/admin.py tests/api/test_admin.py
All checks passed!

python -m ruff format --check app/db/crud/admin.py tests/api/test_admin.py
2 files already formatted

Screenshots

Not applicable.

Notes for reviewers

This uses Pydantic's model_fields_set to preserve partial-update semantics: omitting data_limit leaves it unchanged, while explicitly sending null clears it. No database migration or API schema change is required, and data_limit: 0 remains supported for backward compatibility.

Summary by CodeRabbit

  • Bug Fixes

    • Admin data limits can now be explicitly cleared by setting them to null.
    • Omitting the data limit preserves its existing value.
    • Non-positive limits continue to be treated as unlimited.
  • Tests

    • Added coverage confirming the distinction between omitted and explicitly cleared data limits.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 48645cf8-d9bb-4983-940c-33a05d4bc0e9

📥 Commits

Reviewing files that changed from the base of the PR and between 5c553a0 and 09ff21e.

📒 Files selected for processing (2)
  • app/db/crud/admin.py
  • tests/api/test_admin.py

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


Walkthrough

The admin update logic now distinguishes omitted data_limit values from explicit null. Explicit null clears the limit, while omitted values preserve it. A regression test covers setting, preserving, and clearing the limit.

Changes

Admin data limit updates

Layer / File(s) Summary
Normalize updates and validate null clearing
app/db/crud/admin.py, tests/api/test_admin.py
update_admin preserves omitted data_limit values and converts explicit null or non-positive values to None. The regression test verifies setting, preserving, and clearing the limit.

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

Merge Risk: ⚪ Minimal · up to 09ff2

This change distinguishes omitted, zero, and explicit-null data-limit updates so administrators can clear a limit without changing existing behavior; no actionable merge-blocking risk remains.

Suggested reviewers: m03ed, x0sina, immohammad20000

Poem

A rabbit set the limit bright,
Then left omitted fields just right.
With null, the limit hopped away,
Tests guard the path today.
Thump, thump—clean updates stay!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the fix that allows administrators to clear the data limit by sending null.
Linked Issues check ✅ Passed The changes distinguish omitted and explicit null values, clear the persisted limit, preserve zero behavior, and add regression coverage for issue #802.
Out of Scope Changes check ✅ Passed The code and regression test changes directly support the linked issue and stated objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@dr-hoseyn

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
✅ 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.

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.

1 participant