Skip to content

Add bulletin acp rpc#97

Open
JesseAbram wants to merge 2 commits intodevfrom
jesse/add_bulletin_acp_rpc
Open

Add bulletin acp rpc#97
JesseAbram wants to merge 2 commits intodevfrom
jesse/add_bulletin_acp_rpc

Conversation

@JesseAbram
Copy link
Contributor

Adds an endpoint to get the bulletin policy Id this is needed for https://github.com/sourcenetwork/orbis-rs/issues/93 . The check on orbis side would be this policyId + bulletin/namespace (object_id) + permission

@JesseAbram JesseAbram requested review from Lodek and iverc March 19, 2026 15:27
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f655155-cecb-42a1-8ee2-f21d90a93abc

📥 Commits

Reviewing files that changed from the base of the PR and between a3496e0 and 32ac95c.

📒 Files selected for processing (1)
  • x/bulletin/keeper/grpc_query_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/bulletin/keeper/grpc_query_test.go
📜 Recent review details
⏰ 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: test

📝 Walkthrough

Walkthrough

Adds a new gRPC query RPC BulletinPolicyId with proto request/response messages, its keeper handler implementing input validation and NotFound handling, and unit tests for success, nil-request, and missing-policy cases.

Changes

Cohort / File(s) Summary
Proto definition
proto/sourcehub/bulletin/query.proto
Added BulletinPolicyId RPC and new messages QueryBulletinPolicyIdRequest and QueryBulletinPolicyIdResponse (includes policy_id).
Keeper gRPC handler
x/bulletin/keeper/grpc_query.go
Added Keeper.BulletinPolicyId method: nil-request check, fetches policy ID via k.GetPolicyId(ctx), returns NotFound if empty, otherwise returns response with PolicyId.
Unit tests
x/bulletin/keeper/grpc_query_test.go
Added three tests: success path (asserts returned PolicyId), nil-request (expects InvalidArgument), and empty-policy (expects NotFound).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

📝 Coding Plan
  • Generate coding plan for human review comments

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.

🧹 Nitpick comments (1)
x/bulletin/keeper/grpc_query_test.go (1)

396-412: Prefer asserting gRPC status codes over error strings.

These tests are correct, but using status.Code(err) (or status.FromError) is more robust than substring checks.

Proposed test hardening
 import (
 	"testing"

 	"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
 	sdk "github.com/cosmos/cosmos-sdk/types"
 	query "github.com/cosmos/cosmos-sdk/types/query"
 	authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
 	"github.com/stretchr/testify/require"
+	"google.golang.org/grpc/codes"
+	"google.golang.org/grpc/status"

 	"github.com/sourcenetwork/sourcehub/x/bulletin/types"
 )
@@
 func TestBulletinPolicyIdQuery_InvalidRequest(t *testing.T) {
 	k, ctx := setupKeeper(t)

 	response, err := k.BulletinPolicyId(ctx, nil)
 	require.Error(t, err)
-	require.Contains(t, err.Error(), "invalid request")
+	require.Equal(t, codes.InvalidArgument, status.Code(err))
 	require.Nil(t, response)
 }
@@
 func TestBulletinPolicyIdQuery_PolicyNotSet(t *testing.T) {
 	k, ctx := setupKeeper(t)

 	response, err := k.BulletinPolicyId(ctx, &types.QueryBulletinPolicyIdRequest{})
 	require.Error(t, err)
-	require.Contains(t, err.Error(), types.ErrInvalidPolicyId.Error())
+	require.Equal(t, codes.NotFound, status.Code(err))
 	require.Nil(t, response)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@x/bulletin/keeper/grpc_query_test.go` around lines 396 - 412, Replace fragile
substring assertions with gRPC status code checks: in
TestBulletinPolicyIdQuery_InvalidRequest call status.Code(err) and assert it
equals codes.InvalidArgument after invoking k.BulletinPolicyId, and in
TestBulletinPolicyIdQuery_PolicyNotSet assert status.Code(err) equals
codes.NotFound (and still ensure response is nil); reference the test functions
TestBulletinPolicyIdQuery_InvalidRequest and
TestBulletinPolicyIdQuery_PolicyNotSet and the call k.BulletinPolicyId and the
domain error types.ErrInvalidPolicyId when updating the assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@x/bulletin/keeper/grpc_query_test.go`:
- Around line 396-412: Replace fragile substring assertions with gRPC status
code checks: in TestBulletinPolicyIdQuery_InvalidRequest call status.Code(err)
and assert it equals codes.InvalidArgument after invoking k.BulletinPolicyId,
and in TestBulletinPolicyIdQuery_PolicyNotSet assert status.Code(err) equals
codes.NotFound (and still ensure response is nil); reference the test functions
TestBulletinPolicyIdQuery_InvalidRequest and
TestBulletinPolicyIdQuery_PolicyNotSet and the call k.BulletinPolicyId and the
domain error types.ErrInvalidPolicyId when updating the assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81c24755-bcf8-48a3-bc78-9aefbb753e5d

📥 Commits

Reviewing files that changed from the base of the PR and between 849ddc0 and a3496e0.

⛔ Files ignored due to path filters (2)
  • x/bulletin/types/query.pb.go is excluded by !**/*.pb.go
  • x/bulletin/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
📒 Files selected for processing (3)
  • proto/sourcehub/bulletin/query.proto
  • x/bulletin/keeper/grpc_query.go
  • x/bulletin/keeper/grpc_query_test.go
📜 Review details
⏰ 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: test
🔇 Additional comments (3)
x/bulletin/keeper/grpc_query.go (1)

287-299: Clean and consistent query handler implementation.

Nil-request validation, unset-policy handling, and response construction are all aligned with the module’s existing gRPC query patterns.

x/bulletin/keeper/grpc_query_test.go (1)

386-395: Great coverage for the happy path.

This validates the new endpoint behavior end-to-end with the keeper setup and policy initialization.

proto/sourcehub/bulletin/query.proto (1)

52-55: Proto additions look solid and coherent.

The new RPC, HTTP mapping, and request/response messages are cleanly additive and consistent with the existing query service structure.

Also applies to: 125-131

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.87%. Comparing base (849ddc0) to head (a3496e0).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #97      +/-   ##
==========================================
+ Coverage   47.84%   47.87%   +0.02%     
==========================================
  Files         276      276              
  Lines       16195    16202       +7     
==========================================
+ Hits         7749     7756       +7     
  Misses       7642     7642              
  Partials      804      804              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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