Skip to content

[bug]: DX Issues with ShelbyNetwork type & ShelbyRPCClient.putBlob error messaging #34

@adityaypz

Description

@adityaypz

Affected product

SDK (JS/TS)

Version / Commit / Build

@shelby-protocol/sdk/node latest

Platform / Environment

Node

Steps to Reproduce

  1. Setup a Node.js project using TypeScript and @shelby-protocol/sdk.
  2. Enable strict: true in tsconfig.json.
  3. Try to configure a client using ShelbyNetwork as a value:
    const client = new ShelbyClient({ network: ShelbyNetwork.Devnet });
  4. Try to upload a blob directly using ShelbyRPCClient.putBlob without first registering the commitments on-chain via the coordination client.

Expected Behavior

  1. ShelbyNetwork should be usable as a configuration value without throwing a TypeScript error.
  2. ShelbyRPCClient.putBlob should return a clear developer-friendly error (e.g., 400 Bad Request or a descriptive message) if on-chain commitments haven't been made, explaining what step the developer missed.

Actual Behavior & Errors

  1. TypeScript strict mode throws an error when trying to use ShelbyNetwork as a value: 'ShelbyNetwork' only refers to a type, but is being used as a value here. This forces developers to cast it as string/any (network: "shelbynet" as any).
  2. Calling ShelbyRPCClient.putBlob directly without prior on-chain commitments results in a confusing generic HTTP 404 error from the RPC Node, which might make developers think the RPC endpoint is down or incorrect:
    {"message":"not found","error_code":"web_framework_error","vm_error_code":null}

Logs / Screenshots

// test.ts (Snippet demonstrating the issues)

import { Aptos, AptosConfig, Network, Account } from "@aptos-labs/ts-sdk";
import { ShelbyClient, ShelbyNetwork } from "@shelby-protocol/sdk/node";

async function runTests() {
  // 🐛 DX Issue 1: ShelbyNetwork type forcing "as any" or "as ShelbyNetwork"
  // Using ShelbyNetwork.Devnet directly throws: 
  // TS2693: 'ShelbyNetwork' only refers to a type, but is being used as a value here.
  const shelby = new ShelbyClient({
      network: "shelbynet" as any, 
      rpc: { baseUrl: "https://api.shelbynet.shelby.xyz" }
  });

  const dummyBuffer = new Uint8Array(Buffer.from("Test Data", "utf-8"));
  const account = Account.generate();

  // 🐛 DX Issue 2: putBlob returns confusing 404 if no prior blockchain commitments exist
  try {
      // Assuming a developer tries to use ShelbyRPCClient standalone:
      // await shelbyRPC.putBlob({ ... }); 
      
      // Expected Error: "Blob commitments not found on Aptos chain"
      // Actual Error Received:
      // Error: Failed to start multipart upload! status: 404, body: {"message":"not found","error_code":"web_framework_error","vm_error_code":null}
  } catch(e) {
      console.error(e);
  }
}

Contact (Optional)

https://github.com/adityaypz

Pre-Checks

  • I've searched existing issues
  • This is not a security vulnerability (see SECURITY.md)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions