Skip to content

Comments

fix: update configuration <> expense pull#858

Open
ashwin1111 wants to merge 1 commit intomasterfrom
fix-update-config-expense-pull
Open

fix: update configuration <> expense pull#858
ashwin1111 wants to merge 1 commit intomasterfrom
fix-update-config-expense-pull

Conversation

@ashwin1111
Copy link
Contributor

@ashwin1111 ashwin1111 commented Oct 15, 2025

Description

Please add PR description here, add screenshots if needed

Clickup

https://app.clickup.com/

Summary by CodeRabbit

  • Bug Fixes
    • Actions tied to Expense Group Settings now run after settings are saved, improving reliability and preventing intermittent issues where changes weren’t fully applied.
  • Refactor
    • Adjusted internal event timing for settings updates to execute post-save, enhancing stability and consistency of related workflows.

@github-actions github-actions bot added the size/XS Extra Small PR label Oct 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Switches ExpenseGroupSettings signal handling from pre_save to post_save in apps/fyle/signals.py, renaming the receiver accordingly, updating the decorator, adjusting the docstring, and removing the unused pre_save import.

Changes

Cohort / File(s) Summary
Signals: ExpenseGroupSettings post-save handler
apps/fyle/signals.py
Replace pre_save with post_save receiver; rename handler to run_post_save_expense_group_setting_triggers; update docstring; remove pre_save import.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Model as ExpenseGroupSettings (Model)
    participant ORM as Django ORM
    participant Signal as post_save Receiver

    User->>Model: set fields
    User->>ORM: Model.save()
    ORM->>Model: write to DB
    Note right of ORM: Save committed
    ORM-->>Signal: emit post_save(instance)
    Signal->>Signal: run_post_save_expense_group_setting_triggers(instance)
    Signal-->>User: processing complete
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through signals, quick and brave,
From pre to post, after the save.
A whisker twitch, imports trimmed,
New name, same trail—logic primmed.
Thump-thump! The flow now neatly paved. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description still contains the placeholder text from the template and does not explain what was changed or why, so it fails to meet the repository’s requirement for a substantive PR description even though the ClickUp link is provided. Please replace the placeholder in the Description section with a concise summary of the actual changes, their purpose, and any relevant context or screenshots to fully satisfy the template.
Title Check ❓ Inconclusive The title “fix: update configuration <> expense pull” is vague and does not clearly summarize the primary change of switching from a pre_save to a post_save signal on ExpenseGroupSettings, making it difficult for reviewers to understand the main purpose at a glance. Please revise the title to explicitly reflect the main change, for example “fix: replace pre_save with post_save signal for ExpenseGroupSettings triggers,” so that it clearly conveys the core update.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-update-config-expense-pull

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 and usage tips.

@github-actions
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
apps
   exceptions.py431467%23, 29, 35–40, 46, 52–57, 63, 69, 75–76, 88–90
apps/fyle
   actions.py132993%32–35, 280, 328–332
   constants.py10100% 
   helpers.py2565080%110–112, 121, 132–136, 174–182, 279, 337, 340–356, 381–387, 390, 393, 454–478
   models.py3221197%297–299, 303–305, 320, 359–363, 536, 555
   queue.py290100% 
   serializers.py340100% 
   signals.py31777%30–32, 49–50, 53–54
   tasks.py3988579%156–157, 164–166, 196–197, 224–225, 252–253, 267–272, 297, 307, 317–320, 329, 339–368, 379–415, 463–465, 720–721, 766–769, 776–777, 798–799, 840–841, 848–849, 851–852, 855–856, 858–859
   views.py1851393%77, 90, 93, 177, 367, 404–412, 428–432
apps/internal
   actions.py22291%15–16
   views.py390100% 
apps/mappings
   constants.py30100% 
   exceptions.py1257441%58, 61–62, 65–66, 69–74, 99–178
   helpers.py32778%49–53, 60–62
   models.py460100% 
   queue.py362822%17–106
   schedules.py120100% 
   serializers.py36197%38
   signals.py95991%146–148, 152–153, 180–186
   tasks.py1821691%32, 55, 109–110, 192–193, 204, 312–316, 369–372, 417–423
   views.py43198%104
apps/netsuite
   actions.py34391%45, 56–57
   connector.py89611587%89–94, 145, 161, 164, 167, 173, 246, 258, 269, 436, 453, 457, 487, 504, 508, 591, 606, 610–611, 630, 695, 698–702, 751, 796, 822–823, 828, 854, 959, 964–967, 978–981, 990–991, 1030–1031, 1071, 1251–1265, 1288–1290, 1475, 1477, 1480, 1492, 1495, 1639–1642, 1671–1677, 1727, 1845, 1961, 1999–2028, 2045–2048, 2252, 2552, 2707, 2718, 2732–2733, 2737–2739
   errors.py624429%21–26, 46–70, 76–84, 103–113, 119, 134–147
   errors_reference.py40100% 
   exceptions.py1392979%85, 95–96, 138, 151–152, 187–209, 212–235
   helpers.py793852%20–29, 60–61, 92–114, 119–136, 149–150
   models.py6412596%66, 99, 127, 164, 197, 252, 254, 258, 301, 322, 509, 513, 536–537, 724, 728, 751–752, 956, 960, 978–979, 1159, 1178, 1182
   queue.py1371291%33–36, 62, 109–113, 166–170, 228–232, 284–288
   serializers.py120100% 
   signals.py46589%31–32, 41, 66–67
   tasks.py83215681%153–155, 194, 203, 250–251, 258, 264, 425–452, 480–484, 492–493, 546–547, 571–575, 583–584, 656–657, 678–682, 690–691, 739–740, 765–769, 777–778, 826–827, 1021, 1144, 1177–1182, 1221, 1291–1314, 1324–1326, 1348, 1363, 1367–1373, 1419–1427, 1501–1522, 1535–1545, 1548, 1552–1583
   views.py94694%99, 166–167, 197, 213–214
apps/tasks
   helpers.py100100% 
   models.py650100% 
   serializers.py60100% 
   views.py190100% 
apps/users
   helpers.py120100% 
   models.py140100% 
   views.py230100% 
apps/workspaces
   actions.py46198%126
   helpers.py6267%7, 15
   models.py1190100% 
   permissions.py33973%24, 43–51
   serializers.py490100% 
   signals.py330100% 
   tasks.py1541392%73–77, 100, 176, 207–208, 317–320
   utils.py13562%24–33
   views.py2532391%102–105, 140–150, 170, 494–509
apps/workspaces/apis/advanced_settings
   serializers.py87397%196, 199, 202
   triggers.py120100% 
   views.py70100% 
apps/workspaces/apis/errors
   serializers.py200100% 
   views.py110100% 
apps/workspaces/apis/export_settings
   helpers.py71396%133–135
   serializers.py95397%202, 205, 208
   triggers.py36489%41, 56–57, 66
   views.py110100% 
apps/workspaces/apis/import_settings
   serializers.py74199%172
   triggers.py782371%25–40, 43–61, 69
   views.py110100% 
apps/workspaces/apis/map_employees
   serializers.py37295%23, 58
   triggers.py6183%10
   views.py11464%11, 18–20
workers/export
   actions.py11191%20
   worker.py46589%28–29, 54–55, 82
TOTAL655786387% 

Tests Skipped Failures Errors Time
292 0 💤 2 ❌ 0 🔥 34.273s ⏱️

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/fyle/signals.py (1)

40-54: Critical: state-change detection broken with post_save signal

  • With post_save, existing_expense_group_setting reflects the newly saved values, so existing_expense_group_setting.expense_state != instance.expense_state is always false and async tasks never run.
  • Revert to pre_save on ExpenseGroupSettings to compare old (DB) vs new (instance) values for proper change detection.
🧹 Nitpick comments (1)
apps/fyle/signals.py (1)

36-36: Static analysis: Unused signal parameters.

The static analysis tool flags sender and kwargs as unused. For Django signals:

  • sender is typically unused but part of the signal protocol. If desired, prefix with underscore: _sender
  • kwargs contains important signal metadata like created, update_fields, raw, and using. With post_save, you should examine kwargs.get('created') to distinguish creates from updates.

Given the critical issue identified in the previous comment, properly using kwargs becomes important if you keep the post_save signal.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 723f832 and d0f05af.

📒 Files selected for processing (1)
  • apps/fyle/signals.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/fyle/signals.py (1)
apps/fyle/models.py (1)
  • ExpenseGroupSettings (236-348)
🪛 Ruff (0.14.0)
apps/fyle/signals.py

36-36: Unused function argument: sender

(ARG001)


36-36: Unused function argument: kwargs

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: pytest

import logging

from django.db.models.signals import post_save, pre_save
from django.db.models.signals import post_save
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Signal change breaks state-change detection logic.

The switch from pre_save to post_save fundamentally breaks the change-detection mechanism in this signal handler. See the detailed explanation in the review comment on lines 40-54.

Also applies to: 35-35

🤖 Prompt for AI Agents
In apps/fyle/signals.py around lines 3 and also affecting line 35, the signal
import was changed from pre_save to post_save which breaks existing state-change
detection; revert the import to django.db.models.signals.pre_save (and
corresponding decorator/connection) so the handler runs before the DB write, and
restore the original pre-save comparison logic that compares the incoming
instance to the existing DB state (or use a DB fetch inside the pre_save handler
if snapshotting was removed); apply the same revert at line 35 to ensure all
handlers relying on pre-save change detection run before persistence.

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

Labels

size/XS Extra Small PR

Development

Successfully merging this pull request may close these issues.

2 participants