Skip to content

Comments

refactor(provider/client): use protobuf BidScreeningResponse for Vali…#244

Merged
troian merged 1 commit intomainfrom
refactor/provider-client-bid-screening
Feb 24, 2026
Merged

refactor(provider/client): use protobuf BidScreeningResponse for Vali…#244
troian merged 1 commit intomainfrom
refactor/provider-client-bid-screening

Conversation

@troian
Copy link
Member

@troian troian commented Feb 24, 2026

…date

📝 Description

[Explain what this PR does in 2-3 sentences. Include context about the feature or problem being solved]

🔧 Purpose of the Change

  • New feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Dependency upgrade
  • Other: [specify]

📌 Related Issues

  • Closes #ISSUE_NUMBER
  • References #ISSUE_NUMBER

✅ Checklist

  • I've updated relevant documentation
  • Code follows Akash Network's style guide
  • I've added/updated relevant unit tests
  • Dependencies have been properly updated
  • I agree and adhered to the Contribution Guidelines

📎 Notes for Reviewers

[Include any additional context, architectural decisions, or specific areas to focus on]

…date

Signed-off-by: Artur Troian <troian@users.noreply.github.com>
@troian troian requested a review from a team as a code owner February 24, 2026 02:48
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Walkthrough

The changes replace a custom ValidateGroupSpecResult return type with the protobuf-generated providerv1.BidScreeningResponse type in the provider client's Validate method, updating the method signature and removing the now-unused type definition.

Changes

Cohort / File(s) Summary
Validate Method & Return Type Refactoring
go/provider/client/client.go, go/provider/client/types.go
Updated Validate method to return (*providerv1.BidScreeningResponse, error) instead of (ValidateGroupSpecResult, error). Added import for providerv1, adjusted error returns to (nil, err), and removed the ValidateGroupSpecResult type definition and associated sdk import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A type once lived in client code,
Now replaced with proto's load,
BidScreeningResponse takes the stage,
ValidateGroupSpecResult turns the page! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description uses the provided template but fails to complete the critical 📝 Description section - it shows only the placeholder text without explaining what the PR does or providing context about the problem being solved. Complete the 📝 Description section with 2-3 sentences explaining the refactoring's purpose, benefits, and why using BidScreeningResponse is preferred over the previous ValidateGroupSpecResult.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: refactoring the provider/client code to use the protobuf BidScreeningResponse type for the Validate method. The change aligns with the file modifications described in the raw_summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/provider-client-bid-screening

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

Copy link
Contributor

@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)
go/provider/client/client.go (1)

411-413: Use protojson instead of encoding/json for protobuf message decoding.

At line 412, BidScreeningResponse (a protobuf message) is decoded using encoding/json. The standard JSON encoder does not honor protobuf JSON field mappings—specifically, the ResourceOffer field has a protobuf json_name of resourceOffer but the Go struct tag expects resource_offer. If the validate endpoint returns protobuf-formatted JSON, this mismatch will cause the field to be silently dropped. Use protojson.Unmarshal instead.

🔧 Suggested change
 import (
   "bytes"
   "context"
   "crypto"
   "crypto/tls"
   "crypto/x509"
   "encoding/json"
   "errors"
   "fmt"
   "io"
   "math/big"
   "net/http"
   "net/url"
   "strconv"
   "strings"
   "time"
 
   "github.com/golang-jwt/jwt/v5"
   "github.com/gorilla/websocket"
   "k8s.io/client-go/tools/remotecommand"
+  "google.golang.org/protobuf/encoding/protojson"
   ...
 )
 ...
 var obj providerv1.BidScreeningResponse
-if err = json.NewDecoder(buf).Decode(&obj); err != nil {
+if err = protojson.UnmarshalOptions{DiscardUnknown: true}.Unmarshal(buf.Bytes(), &obj); err != nil {
     return nil, err
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go/provider/client/client.go` around lines 411 - 413, The code decodes a
protobuf message using encoding/json which doesn’t respect protobuf JSON
mappings; replace the json.NewDecoder(buf).Decode(&obj) call for
providerv1.BidScreeningResponse with protojson.Unmarshal on the buffer bytes
(e.g., protojson.Unmarshal(buf.Bytes(), &obj)) and add the
google.golang.org/protobuf/encoding/protojson import so the ResourceOffer and
other protobuf-json mapped fields are decoded correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@go/provider/client/client.go`:
- Around line 411-413: The code decodes a protobuf message using encoding/json
which doesn’t respect protobuf JSON mappings; replace the
json.NewDecoder(buf).Decode(&obj) call for providerv1.BidScreeningResponse with
protojson.Unmarshal on the buffer bytes (e.g., protojson.Unmarshal(buf.Bytes(),
&obj)) and add the google.golang.org/protobuf/encoding/protojson import so the
ResourceOffer and other protobuf-json mapped fields are decoded correctly.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fadf95 and 723f403.

📒 Files selected for processing (2)
  • go/provider/client/client.go
  • go/provider/client/types.go
💤 Files with no reviewable changes (1)
  • go/provider/client/types.go

@troian troian merged commit 8e90b7f into main Feb 24, 2026
7 checks passed
@troian troian deleted the refactor/provider-client-bid-screening branch February 24, 2026 03:01
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.

1 participant