windmill-labs/windmill · error · Error

deleteS3File: s3 key is required

Error message

deleteS3File: s3 key is required

What it means

Thrown by deleteS3File after parseS3Object when the resulting object has no `s3` key set. The S3Object payload type permits other storage identifiers, but this helper deletes strictly by raw S3 key, so a file-path-style or storage-scoped object is rejected before the API call.

Source

Thrown at typescript-client/client.ts:1048

}

/**
 * Permanently delete a file from S3 by key.
 *
 * ```typescript
 * await wmill.deleteS3File({ s3: "path/to/file.txt" })
 * ```
 *
 * @param s3object - S3 object identifying the file to delete (must have `s3` set)
 * @param workspace - Workspace to delete from (defaults to the `WM_WORKSPACE` env var)
 */
export async function deleteS3File(
  s3object: S3Object,
  workspace: string | undefined = undefined
): Promise<void> {
  const s3Obj = parseS3Object(s3object);
  if (!s3Obj.s3) {
    throw new Error("deleteS3File: s3 key is required");
  }
  await HelpersService.deleteS3File({
    workspace: workspace ?? getWorkspace(),
    fileKey: s3Obj.s3,
    storage: s3Obj.storage,
  });
}

/**
 * Sign S3 objects to be used by anonymous users in public apps
 * @param s3objects s3 objects to sign
 * @param expirySecs how long the signature stays valid, in seconds (default 43200 = 12h, clamped to [60, 604800])
 * @returns signed s3 objects
 */
export async function signS3Objects(
  s3objects: S3Object[],
  { expirySecs }: { expirySecs?: number } = {}
): Promise<S3Object[]> {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Provide an S3Object with a valid s3 key
  2. Use parseS3Object on a correct 'storage/key' string so s3 is populated
  3. If the target is a storage (workspace) file rather than an S3 object, use the appropriate storage deletion API instead

Example fix

// before
await deleteS3File({ storage: 'my_folder' })
// after
await deleteS3File({ s3: 'my_folder/file.txt', storage: 's3' })
Defensive patterns

Strategy: validation

Validate before calling

const parsed = parseS3Object(s3object)
if (!parsed.s3) throw new Error('S3Object must include an s3 key before deletion')

Type guard

function isDeletableS3Object(o: S3Object): boolean {
  return !!parseS3Object(o).s3
}

Try / catch

try {
  await deleteS3File(s3object, workspace)
} catch (e) {
  if (e.message.includes('s3 key is required')) console.error('Provide an S3Object with an s3 key')
  else throw e
}

Prevention

When it happens

Trigger: Calling deleteS3File with an S3Object whose parsed `s3` field is empty/undefined — e.g. an object built from a storage-only path.

Common situations: Passing a file path instead of an S3 key; an S3Object coming from an API response where only `storage` was populated; malformed "storage/path" string.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/f2bd530ecbf8a331. Report an issue: GitHub.