Skip to content

fix(oracle): return error instead of nil in RemoveExcessFeeds#244

Merged
Thaleszh merged 4 commits into
KiiChain:mainfrom
ngapaxs:fix/oracle-remove-excess-feeds-error
Jan 28, 2026
Merged

fix(oracle): return error instead of nil in RemoveExcessFeeds#244
Thaleszh merged 4 commits into
KiiChain:mainfrom
ngapaxs:fix/oracle-remove-excess-feeds-error

Conversation

@ngapaxs

@ngapaxs ngapaxs commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Description

found a typo in RemoveExcessFeeds - when ExchangeRate.Remove fails it was doing return nil instead of return err. this swallows the error so the caller never knows removal failed.

split from #234 per maintainer request

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

ran the existing test to make sure nothing broke:

  • TestRemoveExcessFeeds - passes

PR Checklist:

  • Updated changelog with PR's intent
  • Lint with make lint-fix

@ngapaxs ngapaxs requested a review from jhelison as a code owner January 21, 2026 13:55
@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

RemoveExcessFeeds in x/oracle/keeper/keeper.go was changed to log errors and continue processing remaining denoms when removing an exchange rate fails, instead of returning immediately. A new test TestRemoveExcessFeedsWithError was added to x/oracle/keeper/keeper_test.go to exercise this non-abortive behavior and verify valid exchange rates remain accessible. CHANGELOG.md was updated under UNRELEASED with a note about Return error instead of nil in RemoveExcessFeeds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main bug fix: returning an error instead of nil in RemoveExcessFeeds, which directly matches the core change.
Description check ✅ Passed The description clearly explains the bug found (returning nil instead of error in RemoveExcessFeeds), the impact, and references the changelog update, directly relating to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 20: Changelog contains a duplicate entry for "Return error instead of nil
in RemoveExcessFeeds"; decide which place should remain and remove the
duplicate: if this change is new and unreleased, keep the UNRELEASED entry (the
one referencing RemoveExcessFeeds) and delete the v6.0.0 duplicate; if it was
already released in v6.0.0, delete the UNRELEASED line instead—ensure only one
entry referencing RemoveExcessFeeds remains.

Comment thread CHANGELOG.md
@codecov

codecov Bot commented Jan 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
x/oracle/keeper/keeper.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Thaleszh Thaleszh left a comment

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.

Need to remove duplicated entry on changelog and review behavior change

Comment thread CHANGELOG.md Outdated
Comment thread x/oracle/keeper/keeper.go Outdated
@ngapaxs ngapaxs force-pushed the fix/oracle-remove-excess-feeds-error branch 5 times, most recently from 385df7b to 0af406f Compare January 23, 2026 01:15

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@x/oracle/keeper/keeper_test.go`:
- Around line 719-732: The test uses undefined constants TEST1, TEST2, and EXTRA
which will fail to compile; update calls to oracleKeeper.VoteTarget.Set and
oracleKeeper.SetBaseExchangeRateWithDefault to use the existing utils constants
instead: replace TEST1 with utils.AtomDenom, TEST2 with utils.EthDenom, and
EXTRA with utils.KiiDenom so the Set and SetBaseExchangeRateWithDefault
invocations compile and use the intended denoms.
🧹 Nitpick comments (1)
x/oracle/keeper/keeper_test.go (1)

711-741: Test does not actually verify error handling behavior.

The test is named TestRemoveExcessFeeds_ErrorHandling and claims to test that "errors are logged and processing continues," but it:

  1. Does not inject any errors or mock storage failures
  2. Does not verify that errors are logged
  3. Only tests the happy path where all removals succeed

This test is functionally equivalent to the existing TestRemoveExcessFeeds test (lines 345-377). To properly test error handling, consider:

  • Mocking ExchangeRate.Remove to return an error for specific denoms
  • Verifying that RemoveExcessFeeds continues processing after encountering errors
  • Capturing and asserting on log output

Comment thread x/oracle/keeper/keeper_test.go Outdated
@ngapaxs ngapaxs force-pushed the fix/oracle-remove-excess-feeds-error branch from 0af406f to 385df7b Compare January 23, 2026 01:28
Comment thread CHANGELOG.md Outdated
@ngapaxs ngapaxs force-pushed the fix/oracle-remove-excess-feeds-error branch 3 times, most recently from d704c79 to fe2af57 Compare January 24, 2026 08:59

@coderabbitai coderabbitai Bot left a comment

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.

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)
x/oracle/keeper/keeper.go (1)

269-277: Implementation diverges from PR description.

The PR description states this fix "returns the error so callers receive the storage removal failure," but the implementation logs the error and continues, ultimately returning nil. This aligns with the maintainer's feedback to "just warn the behavior" but contradicts the PR title and description.

If logging-and-continue is the intended behavior (which is reasonable for resilience), update the PR description and changelog to accurately reflect this. The current messaging is misleading.

Note: This pattern differs from AddPriceSnapshot (lines 332-336) which returns immediately on Remove failure. Consider whether error handling should be consistent across the keeper.

🤖 Fix all issues with AI agents
In `@go.mod`:
- Line 3: Run `go mod tidy` and commit the resulting updates to go.mod and
go.sum to satisfy the CI check; then restore or confirm the Go version directive
in go.mod (change the current `go 1.23` back to `go 1.23.8` if the patch version
was intentionally removed in the diff) so the file contains the correct `go`
directive and tidy changes.

Comment thread go.mod Outdated
- Fix typo: return err instead of nil when ExchangeRate.Remove fails
- Log error and continue processing instead of returning error immediately
- Add test case TestRemoveExcessFeedsWithError to cover error handling path
- Update CHANGELOG.md with fix entry

This ensures storage errors are properly logged while allowing the function
to continue processing remaining denoms instead of stopping on first error.
@ngapaxs ngapaxs force-pushed the fix/oracle-remove-excess-feeds-error branch from fe2af57 to 6e5b52f Compare January 24, 2026 09:10
@Thaleszh

Copy link
Copy Markdown
Contributor

Just missing linting

@Thaleszh Thaleszh merged commit e90f4e2 into KiiChain:main Jan 28, 2026
5 of 7 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