Skip to content

Incorrect parameter order in VectorStoreFileBatchService.PollStatus method #553

@MrGossett

Description

@MrGossett

This is just like #538, but for VectorStoreFileBatchService.PollStatus.

Summary

The PollStatus method in VectorStoreFileBatchService passes parameters to the Get method in the wrong order, causing API calls to fail with "Invalid 'batch_id'" errors.

Environment

  • SDK Version: v1.12.0 (and likely earlier versions)
  • Go Version: Any
  • OS: Any

Description

The PollStatus method incorrectly swaps the vectorStoreID and batchID parameters when calling the Get method, causing the API to receive a vector store ID where it expects a batch ID.

Code Location

File: polling.go
Method: VectorStoreFileBatchService.PollStatus
Line: 70

Current (Buggy) Code

func (r *VectorStoreFileBatchService) PollStatus(ctx context.Context, vectorStoreID string, batchID string, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFileBatch, error) {
    // ... other code ...
    for {
        batch, err := r.Get(ctx, batchID, vectorStoreID, opts...) // ❌ WRONG ORDER
        // ... rest of method ...
    }
}

Expected (Correct) Code

func (r *VectorStoreFileBatchService) PollStatus(ctx context.Context, vectorStoreID string, batchID string, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFileBatch, error) {
    // ... other code ...
    for {
        batch, err := r.Get(ctx, vectorStoreID, batchID, opts...) // ✅ CORRECT ORDER
        // ... rest of method ...
    }
}

Get Method Signature

The Get method expects parameters in this order:

func (r *VectorStoreFileBatchService) Get(ctx context.Context, vectorStoreID string, batchID string, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)

Error Details

When the bug occurs, the API returns:

{
  "message": "Invalid 'batch_id': 'vs_abcdef...'. Expected an ID that begins with 'vsfb_'.",
  "type": "invalid_request_error",
  "param": "batch_id",
  "code": "invalid_value"
}

The error occurs because:

  1. A vector store ID (starting with vs_) is being passed as the batch_id parameter
  2. The API expects batch IDs to start with vsfb_
  3. This happens because the vector store ID and batch ID are swapped in the method call

Reproduction Steps

  1. Create a vector store file batch
  2. Call PollStatus on the batch
  3. The method will fail with the "Invalid 'batch_id'" error

Example Usage

// This is the correct way to call PollStatus
batch, err := client.VectorStores.FileBatches.PollStatus(ctx, vectorStoreID, batchID, 0)

Impact

  • Severity: High - breaks core functionality for vector store file batch operations
  • Affected Users: Anyone using PollStatus with vector store file batches
  • Workaround: Use the Get method directly instead of PollStatus

Proposed Fix

Change line 70 in polling.go from:

batch, err := r.Get(ctx, batchID, vectorStoreID, opts...)

to:

batch, err := r.Get(ctx, vectorStoreID, batchID, opts...)

Additional Context

This bug affects the polling functionality for vector store file batches, which is essential for monitoring the status of batch operations. The fix is a simple parameter swap that aligns with the method signature and API expectations.

Metadata

Metadata

Assignees

No one assigned

    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