Skip to content

RG-T41 Bug fixes - #525

Merged
ucswift merged 1 commit into
masterfrom
develop
Sep 24, 2026
Merged

ucswift merged 1 commit into
masterfrom
develop

Conversation

@ucswift

@ucswift ucswift commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fixed search index pull retry timing so the backoff interval starts when a pull fails, including after a request timeout, rather than when the attempt began.
  • Prevented occupancy inventories from being recorded as complete when loading a department’s points of interest fails.
  • Added regression coverage confirming that POI lookup failures abort inventory creation, while a successful lookup with no POI types remains a valid empty result.

Functional Impact

  • Search index synchronization will wait the configured backoff period after a failed object-store pull before retrying.
  • Occupancy reconciliation no longer risks creating incomplete inventories that omit POIs due to a repository failure. Existing inventory status and crosswalk data remain unchanged when the lookup fails.
  • Departments with no POI types can still be inventoried successfully.

@Resgrid-Bot

Resgrid-Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ❌
Security ✅
Business Logic ❌

Access your configuration settings here.

​

@request-info

request-info Bot commented Sep 24, 2026

Copy link
Copy Markdown

Thanks for opening this, but we'd appreciate a little more information. Could you update it with more details?

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Resgrid/Core/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: b139e91a-ecf3-440b-8c30-a187d926cc13

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec1bf9 and 15d5fb1.

⛔ Files ignored due to path filters (1)
  • Tests/Resgrid.Tests/Rms/RecordsOccupancyServiceTests.cs is excluded by !**/Tests/**
📒 Files selected for processing (2)
  • Core/Resgrid.Search/LuceneIndexHost.cs
  • Core/Resgrid.Services/Records/RecordsOccupancyService.cs

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The changes adjust background-pull retry timing after failure and make occupancy source collection stop when a POI-type query returns null.

Changes

Search index background pull

Layer / File(s) Summary
Retry timing after pull failure
Core/Resgrid.Search/LuceneIndexHost.cs
After a background pull fails, the host records the failure time as the latest attempt time. The failure count increment remains unchanged. The comment describes serving the last local revision and basing backoff on the failure time.

Occupancy source collection

Layer / File(s) Summary
Handle a null POI-type result
Core/Resgrid.Services/Records/RecordsOccupancyService.cs
CollectSourcesAsync throws InvalidOperationException when the POI-type query returns null. A non-null empty result remains valid.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 15d5f

A failed POI lookup now stops inventory without committing incomplete results, while background pulls retry after failure-based backoff. The added test covers null and empty results; no material merge risk was established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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.
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.
Title check ✅ Passed The title identifies the changes as bug fixes, which matches the pull request. It is broad and does not name the specific fixes, but it remains related to the changeset.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

// Pois carry no DepartmentId column; a department owns its POIs through their POI type. The repository logs and
// returns null on failure (an empty query is an empty list), and treating that as "no POIs" would stamp an
// inventory that never saw them as complete.
var poiTypes = (await _poiTypes.GetPoiTypesByDepartmentIdAsync(departmentId))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

External repository failure in _poiTypes.GetPoiTypesByDepartmentIdAsync(departmentId) can leave the IReadOnlyList<PoiType> poiTypes assignment without department context or return null. Catch Exception, map null to InvalidOperationException, log the failure with _logger.LogError and departmentId, and rethrow the original exception.

Kody rule violation: Add try-catch blocks for external calls

IReadOnlyList<PoiType> poiTypes;
try
{
    poiTypes = (await _poiTypes.GetPoiTypesByDepartmentIdAsync(departmentId)) ?? throw new InvalidOperationException("The department's points of interest could not be loaded.");
}
catch (Exception ex)
{
    _logger.LogError(ex, "Failed to load POI types for department {DepartmentId}", departmentId);
    throw;
}
Prompt for LLM

File Core/Resgrid.Services/Records/RecordsOccupancyService.cs:

Line 498:

External repository failure in `_poiTypes.GetPoiTypesByDepartmentIdAsync(departmentId)` can leave the `IReadOnlyList<PoiType> poiTypes` assignment without department context or return null. Catch `Exception`, map null to `InvalidOperationException`, log the failure with `_logger.LogError` and `departmentId`, and rethrow the original exception.

Suggested Code:

IReadOnlyList<PoiType> poiTypes;
try
{
    poiTypes = (await _poiTypes.GetPoiTypesByDepartmentIdAsync(departmentId)) ?? throw new InvalidOperationException("The department's points of interest could not be loaded.");
}
catch (Exception ex)
{
    _logger.LogError(ex, "Failed to load POI types for department {DepartmentId}", departmentId);
    throw;
}

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Func<Task> inventory = () => _h.OccupancyService.InventoryCandidatesAsync(Dept, Admin);
await inventory.Should().ThrowAsync<InvalidOperationException>();
_h.Crosswalks.Rows.Should().BeEmpty();
var status = await _h.OccupancyService.GetReconciliationStatusAsync(Dept);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Unhandled task rejection from _h.OccupancyService.GetReconciliationStatusAsync(Dept) can fail the test without useful context at Tests/Resgrid.Tests/Rms/RecordsOccupancyServiceTests.cs:151, corresponding to Core/Resgrid.Services/Records/RecordsOccupancyService.cs:498. Catch Exception and use Assert.Fail to report the reconciliation-status retrieval error.

Kody rule violation: Handle async operations with proper error handling

ReconciliationStatus status;
try
{
    status = await _h.OccupancyService.GetReconciliationStatusAsync(Dept);
}
catch (Exception ex)
{
    Assert.Fail($"Failed to retrieve reconciliation status: {ex.Message}");
    return;
}
Prompt for LLM

File Tests/Resgrid.Tests/Rms/RecordsOccupancyServiceTests.cs:

Line 146:

Unhandled task rejection from `_h.OccupancyService.GetReconciliationStatusAsync(Dept)` can fail the test without useful context at `Tests/Resgrid.Tests/Rms/RecordsOccupancyServiceTests.cs:151`, corresponding to `Core/Resgrid.Services/Records/RecordsOccupancyService.cs:498`. Catch `Exception` and use `Assert.Fail` to report the reconciliation-status retrieval error.

Suggested Code:

ReconciliationStatus status;
try
{
    status = await _h.OccupancyService.GetReconciliationStatusAsync(Dept);
}
catch (Exception ex)
{
    Assert.Fail($"Failed to retrieve reconciliation status: {ex.Message}");
    return;
}

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@ucswift

ucswift commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

Approve

@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.

This PR is approved.

@ucswift
ucswift merged commit a6738d2 into master Sep 24, 2026
18 of 19 checks passed
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