Skip to content

Conversation

@vertex451
Copy link
Contributor

@vertex451 vertex451 commented Jan 5, 2026

Description

Moved x/provider/handler.ErrInternal to the chain-sdk/go/node/provider/v1beta4 package.

Must be merged after akash-network/chain-sdk#181

Testing

Tested by running single node script and querying the non-existed deployment.

Author Checklist

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • (n/a) included comments for documenting Go code
  • (n/a) updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

@vertex451 vertex451 requested a review from a team as a code owner January 5, 2026 09:58
@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

Walkthrough

The changes consolidate error handling by moving the ErrInternal error definition from an exported declaration in the handler package to the types package, updating all internal references and switching the import alias to sdkerrors accordingly.

Changes

Cohort / File(s) Summary
Error Consolidation
x/provider/handler/server.go, x/provider/handler/handler_test.go
Removed exported ErrInternal declaration; updated all error wrapping in CreateProvider, UpdateProvider, and DeleteProvider handlers to reference types.ErrInternal via sdkerrors.Wrapf; test assertions updated to check against types.ErrInternal
Documentation
CHANGELOG.md
Added changelog entry documenting the relocation of ErrInternal from x/provider/handler.ErrInternal to the chain-sdk/go/node/provider/v1beta4 package under Bug Fixes

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Errors now find their rightful home,
No longer exported, they gently roam,
To types they've moved with grace and care,
Sdkerrors wraps them here and there,
Consolidation makes things bright! 🌟

🚥 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #404 requires the API to return HTTP 404 instead of 500 for non-existent deployments. The PR moves ErrInternal and updates error handling to use RegisterWithGRPCCode, which addresses the HTTP status code mapping requirement.
Out of Scope Changes check ✅ Passed All changes (moving ErrInternal, updating imports, adjusting error handling) are directly scoped to addressing the HTTP 404 status code issue for non-existent deployments.
Title check ✅ Passed The PR title 'fix!: moved ErrInternal to the chain-sdk' accurately describes the main refactoring change: relocating the ErrInternal error definition from the local handler package to the chain-sdk package, which is the primary focus of the changeset.
Description check ✅ Passed The PR description accurately describes the changeset: moving ErrInternal from x/provider/handler to chain-sdk/go/node/provider/v1beta4, with testing details and proper context about dependencies.

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

✨ 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 artem/fix/500-instead-of-404

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.

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

Fix all issues with AI Agents 🤖
In @x/provider/handler/server_test.go:
- Around line 1-33: The file ends without a final newline causing a formatting
lint failure; run gofmt (or add a trailing newline) on the test file so the file
containing TestErrorGRPCStatusCodes and references to handler.ErrInternal is
terminated with a newline character (i.e., ensure the file ends with a blank
line) and re-run static checks.
🧹 Nitpick comments (1)
x/provider/handler/server.go (1)

48-48: Inconsistent error wrapping style across the file.

The file uses two different error wrapping approaches:

  • Line 48: ErrInternal.Wrapf("err: %v", err) (method-style)
  • Line 69: sdkerrors.Wrapf(ErrInternal, "err: %v", err) (function-style)
  • Line 88: ErrInternal.Wrap("NOTIMPLEMENTED") (method-style)

For maintainability and code consistency, all error wrapping should use the same approach.

🔎 Standardize to method-style wrapping
-	return nil, sdkerrors.Wrapf(ErrInternal, "err: %v", err)
+	return nil, ErrInternal.Wrapf("err: %v", err)

Also applies to: 69-69, 88-88

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56645e3 and 6394498.

📒 Files selected for processing (2)
  • x/provider/handler/server.go
  • x/provider/handler/server_test.go
🧰 Additional context used
🧬 Code graph analysis (2)
x/provider/handler/server_test.go (1)
x/provider/handler/server.go (1)
  • ErrInternal (18-18)
x/provider/handler/server.go (1)
x/market/alias.go (1)
  • ModuleName (13-13)
🪛 golangci-lint (2.5.0)
x/provider/handler/server_test.go

[error] 34-34: File is not properly formatted

(gofmt)

⏰ 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). (2)
  • GitHub Check: release-dry-run
  • GitHub Check: build-macos
🔇 Additional comments (2)
x/provider/handler/server.go (2)

6-7: LGTM! Proper imports for gRPC error mapping.

The addition of sdkerrors and google.golang.org/grpc/codes imports enables proper gRPC status code registration.


18-18: Excellent fix for proper HTTP/gRPC status mapping.

Using RegisterWithGRPCCode with codes.Internal ensures this error correctly maps to HTTP 500 (Internal Server Error) instead of defaulting to an incorrect status code. This aligns with the PR objective to fix error propagation.

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: 3

🤖 Fix all issues with AI agents
In @x/provider/handler/server.go:
- Line 82: The build fails because server.go returns
types.ErrInternal.Wrap("NOTIMPLEMENTED") but the symbol types.ErrInternal is
undefined; fix by either (A) replacing that reference with an existing error
value or constructor used elsewhere (e.g., the project-wide internal error
constant/function) or (B) defining ErrInternal in the types package with the
same error type/shape expected here (and ensuring the Wrap method is available
or using the appropriate error-wrapping utility). Update the return in the
handler in server.go to use the correct existing error symbol or add ErrInternal
to the types package so the Wrap call compiles.
- Line 63: The error is caused by using sdkerrors.Wrapf(types.ErrInternal, ...)
and by types.ErrInternal being undefined; change this call to the same
method-syntax used elsewhere: use types.ErrInternal.Wrapf("err: %v", err). Also
ensure that the types package defines and exports ErrInternal (or import the
correct package that provides ErrInternal) so the symbol compiles; keep the
wrapping style consistent with the other usages (lines using
types.ErrInternal.Wrapf).
- Line 42: The code references types.ErrInternal which no longer exists; update
the call to use the correct error symbol and import (for example replace
types.ErrInternal.Wrapf(...) with sdkerrors.ErrInternal.Wrapf(...) and add the
import "github.com/cosmos/cosmos-sdk/types/errors" aliased as sdkerrors), or
alternatively replace the call with a local/internal error helper (e.g.,
fmt.Errorf or your package's ErrInternal) so the undefined types.ErrInternal is
removed; ensure the change is made where server.go returns nil,
types.ErrInternal.Wrapf(...) and adjust imports accordingly.
🧹 Nitpick comments (1)
x/provider/handler/server.go (1)

6-6: Import alias is fine, but usage is inconsistent.

The import alias change from errorsmod to sdkerrors improves clarity. However, the usage across the file is inconsistent: line 63 uses sdkerrors.Wrapf(types.ErrInternal, ...) while lines 42 and 82 use method syntax types.ErrInternal.Wrapf(...).

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f5e093 and 2a00c30.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • x/provider/handler/handler_test.go
  • x/provider/handler/server.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
🧰 Additional context used
🪛 GitHub Check: build-macos
x/provider/handler/server.go

[failure] 42-42:
undefined: types.ErrInternal


[failure] 63-63:
undefined: types.ErrInternal


[failure] 82-82:
undefined: types.ErrInternal

🪛 golangci-lint (2.5.0)
x/provider/handler/server.go

[error] 42-42: : # pkg.akt.dev/node/x/provider/handler
x/provider/handler/server.go:42:21: undefined: types.ErrInternal
x/provider/handler/server.go:63:37: undefined: types.ErrInternal
x/provider/handler/server.go:82:20: undefined: types.ErrInternal

(typecheck)

⏰ 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). (6)
  • GitHub Check: lint-go
  • GitHub Check: release-dry-run
  • GitHub Check: build-bins
  • GitHub Check: tests
  • GitHub Check: sims
  • GitHub Check: coverage
🔇 Additional comments (1)
x/provider/handler/handler_test.go (1)

256-257: The test code at lines 256-257 is correct. types.ErrInternal is defined in the external package pkg.akt.dev/go/node/provider/v1beta4 and is actively used throughout the codebase (e.g., in x/provider/handler/server.go). No undefined error or build failure exists.

Likely an incorrect or invalid review comment.


if err := ms.provider.Create(ctx, types.Provider(*msg)); err != nil {
return nil, ErrInternal.Wrapf("err: %v", err)
return nil, types.ErrInternal.Wrapf("err: %v", err)
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

Build failure: types.ErrInternal is undefined.

Static analysis confirms that types.ErrInternal is not defined, causing compilation failure. This is the same issue identified in the test file - the dependency on chain-sdk with the moved ErrInternal definition appears to be missing.

🧰 Tools
🪛 GitHub Check: build-macos

[failure] 42-42:
undefined: types.ErrInternal

🪛 golangci-lint (2.5.0)

[error] 42-42: : # pkg.akt.dev/node/x/provider/handler
x/provider/handler/server.go:42:21: undefined: types.ErrInternal
x/provider/handler/server.go:63:37: undefined: types.ErrInternal
x/provider/handler/server.go:82:20: undefined: types.ErrInternal

(typecheck)

🤖 Prompt for AI Agents
In @x/provider/handler/server.go at line 42, The code references
types.ErrInternal which no longer exists; update the call to use the correct
error symbol and import (for example replace types.ErrInternal.Wrapf(...) with
sdkerrors.ErrInternal.Wrapf(...) and add the import
"github.com/cosmos/cosmos-sdk/types/errors" aliased as sdkerrors), or
alternatively replace the call with a local/internal error helper (e.g.,
fmt.Errorf or your package's ErrInternal) so the undefined types.ErrInternal is
removed; ensure the change is made where server.go returns nil,
types.ErrInternal.Wrapf(...) and adjust imports accordingly.


if err := ms.provider.Update(ctx, types.Provider(*msg)); err != nil {
return nil, errorsmod.Wrapf(ErrInternal, "err: %v", err)
return nil, sdkerrors.Wrapf(types.ErrInternal, "err: %v", err)
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

Build failure and inconsistent error wrapping syntax.

Two issues:

  1. types.ErrInternal is undefined (same build failure as lines 42 and 82).
  2. This line uses function syntax sdkerrors.Wrapf(types.ErrInternal, ...) while lines 42 and 82 use method syntax types.ErrInternal.Wrapf(...). Prefer consistent usage throughout the file.
♻️ Standardize to method syntax (assuming types.ErrInternal becomes available)
-		return nil, sdkerrors.Wrapf(types.ErrInternal, "err: %v", err)
+		return nil, types.ErrInternal.Wrapf("err: %v", err)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: build-macos

[failure] 63-63:
undefined: types.ErrInternal

🤖 Prompt for AI Agents
In @x/provider/handler/server.go at line 63, The error is caused by using
sdkerrors.Wrapf(types.ErrInternal, ...) and by types.ErrInternal being
undefined; change this call to the same method-syntax used elsewhere: use
types.ErrInternal.Wrapf("err: %v", err). Also ensure that the types package
defines and exports ErrInternal (or import the correct package that provides
ErrInternal) so the symbol compiles; keep the wrapping style consistent with the
other usages (lines using types.ErrInternal.Wrapf).


// TODO: cancel leases
return nil, ErrInternal.Wrap("NOTIMPLEMENTED")
return nil, types.ErrInternal.Wrap("NOTIMPLEMENTED")
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

Build failure: types.ErrInternal is undefined.

Static analysis confirms the same compilation issue - types.ErrInternal is not available. This line correctly uses the method syntax consistent with line 42, but the error type itself must be defined before this code can build.

🧰 Tools
🪛 GitHub Check: build-macos

[failure] 82-82:
undefined: types.ErrInternal

🤖 Prompt for AI Agents
In @x/provider/handler/server.go at line 82, The build fails because server.go
returns types.ErrInternal.Wrap("NOTIMPLEMENTED") but the symbol
types.ErrInternal is undefined; fix by either (A) replacing that reference with
an existing error value or constructor used elsewhere (e.g., the project-wide
internal error constant/function) or (B) defining ErrInternal in the types
package with the same error type/shape expected here (and ensuring the Wrap
method is available or using the appropriate error-wrapping utility). Update the
return in the handler in server.go to use the correct existing error symbol or
add ErrInternal to the types package so the Wrap call compiles.

@vertex451 vertex451 changed the title fix!: replaced sdkerrors.Register with sdkerrors.RegisterWithGRPCCode for the proper error propagation. fix!: moved ErrInternal to the chain-sdk Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants