windmill-labs/windmill · error

Invalid file extension

Error message

Invalid file extension

What it means

addResourceType on the resources page rejects extensions failing validateFileExtension with 'Invalid file extension'. This guards that the extension is syntactically valid (e.g. alphanumeric, no slashes/spaces) before creating the resource type via the API.

Source

Thrown at frontend/src/routes/(root)/(logged)/resources/+page.svelte:331

		)
		loading.types = false
	}

	async function deleteResource(path: string, account?: number): Promise<void> {
		if (account) {
			OauthService.disconnectAccount({ workspace: $workspaceStore!, id: account })
		}
		await ResourceService.deleteResource({ workspace: $workspaceStore!, path })
		reload()
	}

	async function addResourceType(): Promise<void> {
		if (!newResourceType.isFileset) {
			if (newResourceType.formatExtension === '') {
				throw new Error('Invalid empty file extension (make sure it is selected)')
			}
			if (!validateFileExtension(newResourceType.formatExtension ?? 'txt')) {
				throw new Error('Invalid file extension')
			}
		}
		await ResourceService.createResourceType({
			workspace: $workspaceStore!,
			requestBody: {
				name: (disableCustomPrefix ? '' : 'c_') + newResourceType.name,
				schema: newResourceType.schema,
				description: newResourceType.description,
				format_extension: newResourceType.formatExtension,
				is_fileset: newResourceType.isFileset
			}
		})
		resourceTypeDrawer?.closeDrawer?.()
		sendUserToast('Resource type created')
		loadResourceTypes()
		$resourceTypesStore = undefined
	}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Enter only the bare extension (e.g. 'csv', not '.csv' or 'data.csv')
  2. Remove invalid characters (spaces, dots, slashes) from the extension field
  3. If the type really has variable extensions, mark it as a fileset instead

Example fix

// before
formatExtension: '.csv'
// after
formatExtension: 'csv'
Defensive patterns

Strategy: validation

Validate before calling

const ext = (newResourceType.formatExtension ?? '').replace(/^\./, '')
if (!newResourceType.isFileset && !/^[A-Za-z0-9]+$/.test(ext)) {
  sendUserToast('Extension must be bare alphanumeric, e.g. csv', true)
  return
}

Type guard

function isValidExtension(v: unknown): v is string {
  return typeof v === 'string' && /^[A-Za-z0-9]+$/.test(v)
}

Try / catch

try {
  await addResourceType()
} catch (e) {
  if (e.message === 'Invalid file extension') {
    sendUserToast('Use a bare extension like "csv" — no dot, spaces or slashes', true)
  } else throw e
}

Prevention

When it happens

Trigger: Submitting a non-fileset resource type whose formatExtension is non-empty but malformed — contains illegal characters, leading dot, path separators, or whitespace.

Common situations: Typing '.json' (with dot) or 'my file.csv' into the extension field; pasting a filename instead of just the extension; unicode or special characters pasted from external docs.

Related errors


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