supabase/supabase · error · Error

Invalid queue name: must contain only alphanumeric character

Error message

Invalid queue name: must contain only alphanumeric characters, underscores, and hyphens

What it means

Same `isQueueNameValid` guard as the archive mutation, applied to deleteDatabaseQueueMessage before `pgmq.delete(<name>, <msgId>)`. Rejects any queueName failing `/^[a-zA-Z0-9_-]+$/` or the 1-47 char bounds.

Source

Thrown at apps/studio/data/database-queues/database-queue-messages-delete-mutation.ts:24

import { isQueueNameValid } from '@/components/interfaces/Integrations/Queues/Queues.utils'
import { executeSql } from '@/data/sql/execute-sql-mutation'
import type { ResponseError, UseCustomMutationOptions } from '@/types'

export type DatabaseQueueMessageDeleteVariables = {
  projectRef: string
  connectionString?: string | null
  queueName: string
  messageId: number
}

export async function deleteDatabaseQueueMessage({
  projectRef,
  connectionString,
  queueName,
  messageId,
}: DatabaseQueueMessageDeleteVariables) {
  if (!isQueueNameValid(queueName)) {
    throw new Error(
      'Invalid queue name: must contain only alphanumeric characters, underscores, and hyphens'
    )
  }

  const { result } = await executeSql({
    projectRef,
    connectionString,
    sql: safeSql`SELECT * FROM pgmq.delete(${literal(queueName)}, ${literal(messageId)})`,
    queryKey: databaseQueuesKeys.create(),
  })

  return result
}

type DatabaseQueueMessageDeleteData = Awaited<ReturnType<typeof deleteDatabaseQueueMessage>>

export const useDatabaseQueueMessageDeleteMutation = ({
  onSuccess,

View on GitHub (pinned to beee91b9c2)

Solutions

  1. Run the name through `QueueNameSchema.parse()` in the UI before calling the delete mutation.
  2. Trim whitespace and disallow punctuation at the input control.
  3. For externally-created queues with invalid names, rename via SQL first.
Defensive patterns

Strategy: validation

Validate before calling

import { QueueNameSchema } from '@/components/interfaces/Integrations/Queues/Queues.utils'
const parsed = QueueNameSchema.safeParse(queueName)
if (!parsed.success) { throw new Error(parsed.error.issues[0]?.message ?? 'Invalid queue name') }
await deleteDatabaseQueueMessage({ projectRef, connectionString, queueName: parsed.data, messageId })

Type guard

const isValidQueueName = (x: string): x is string => QueueNameSchema.safeParse(x).success

Try / catch

if (!isQueueNameValid(queueName)) { toast.error('Invalid queue name'); return }
try { await deleteDatabaseQueueMessage(vars) } catch (e) { handleError(e) }

Prevention

When it happens

Trigger: deleteDatabaseQueueMessage invoked with a malformed queueName (whitespace, dots, quotes, empty, >47 chars, non-ASCII). Throws before executeSql.

Common situations: Programmatic caller passing an un-sanitized identifier; URL/param drift; a queue created outside Studio with unsupported characters.

Related errors


AI-assisted analysis of supabase/supabase@beee91b9c2 (2026-08-12). Data as JSON: /api/errors/3eb73b53c2c9f987. Report an issue: GitHub.