wavetermdev/waveterm · error
not enough arguments passed %s.%s idx:%d (type %T)
Error message
not enough arguments passed %s.%s idx:%d (type %T)
What it means
CallService maps the method's declared parameters (skipping context.Context and UIContext) onto the JSON args array in webCall.Args one by one. This error is returned when the method requires more positional arguments than the request supplied, i.e. argIdx ran past len(webCall.Args) while parameter idx still needed a value.
Source
Thrown at pkg/service/service.go:342
return webErrorRtn(fmt.Errorf("invalid method: %s.%s", webCall.Service, webCall.Method))
}
var valueArgs []reflect.Value
argIdx := 0
for idx := 0; idx < method.Type().NumIn(); idx++ {
argType := method.Type().In(idx)
if idx == 0 && argType == contextRType {
valueArgs = append(valueArgs, reflect.ValueOf(ctx))
continue
}
if argType == uiContextRType {
if webCall.UIContext == nil {
return webErrorRtn(fmt.Errorf("missing UIContext for %s.%s", webCall.Service, webCall.Method))
}
valueArgs = append(valueArgs, reflect.ValueOf(*webCall.UIContext))
continue
}
if argIdx >= len(webCall.Args) {
return webErrorRtn(fmt.Errorf("not enough arguments passed %s.%s idx:%d (type %T)", webCall.Service, webCall.Method, idx, argType))
}
nativeArg, err := convertArgument(argType, webCall.Args[argIdx])
if err != nil {
return webErrorRtn(fmt.Errorf("cannot convert argument %s.%s type:%T idx:%d error:%v", webCall.Service, webCall.Method, argType, idx, err))
}
valueArgs = append(valueArgs, reflect.ValueOf(nativeArg))
argIdx++
}
retValArr := method.Call(valueArgs)
return convertReturnValues(retValArr)
}
// ValidateServiceArg validates the argument type for a service method
// does not allow interfaces (and the obvious invalid types)
// arguments + return values have special handling for wave objects
func baseValidateServiceArg(argType reflect.Type) error {
if argType == waveObjUpdateRType {
// has special MarshalJSON method, so it is safeView on GitHub (pinned to a4447c1563)
Solutions
- Supply all required positional arguments in webCall.Args in the method's declared order (excluding ctx/UIContext)
- Regenerate/refresh the TypeScript client (tsgen) so arg counts match the backend signatures
- If a parameter is genuinely optional, extend the method or pass an explicit zero value (e.g. false for bool, "" for string)
- Read the idx and type in the message to see exactly which parameter (position, counting ctx) was missing
Example fix
// before
CallService(ctx, WebCallType{Service: "workspace", Method: "CreateWorkspace", Args: ["my-ws"]})
// after
CallService(ctx, WebCallType{Service: "workspace", Method: "CreateWorkspace", Args: ["my-ws", "terminal", "blue", true]}) Defensive patterns
Strategy: validation
Validate before calling
const minArgs = { CreateWorkspace: 4, UpdateWorkspace: 5, CreateWindow: 2 };
function hasEnoughArgs(service, method, args) {
const n = minArgs[method];
return n == null || Array.isArray(args) && args.length >= n;
} Type guard
function argsMatchArity<N extends number>(args: unknown[], n: N): args is { length: N } & unknown[] {
return args.length >= n;
} Try / catch
const rtn = CallService(ctx, call);
if (rtn.Error.startsWith("not enough arguments")) {
console.error(`arity error for ${call.Service}.${call.Method}:`, rtn.Error);
// regenerate client / fix arg list
} Prevention
- Use the generated typed client so arity is checked at compile time
- Regenerate tsgen output whenever a service method signature changes
- Count args as method params minus leading ctx (and UIContext) when hand-building calls
When it happens
Trigger: Sending fewer JSON args than the service method's non-context, non-UIContext parameter count — e.g. CreateWorkspace(ctx, name, icon, color, applyDefaults) called with only 2 args, or a call using an outdated arg count after the method gained a parameter.
Common situations: Frontend/backend version skew after a service method gained a new parameter; hand-built RPC payloads in tests or scripts omitting trailing args; variadic-vs-fixed arg confusion; boolean/optional trailing parameters assumed skippable.
Related errors
- missing UIContext for %s.%s
- command %q expected %d args, got %d
- call ${methodName} error: ${respData.error}
- rpc command "${msg.command}" not supported by [${this.routeI
- msg.error
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/4c21504a0b745dfb.
Report an issue: GitHub.