zitadel/zitadel · error

value must not be empty

Error message

value must not be empty

What it means

Guard panic in the actions JS runtime: AppendMetadataRawFunc was called with an empty (or otherwise unsupported) raw metadata value. Only strings and byte arrays (Uint8Array / 0-255 integer arrays) are accepted as raw values, and the value must not be empty.

Source

Thrown at internal/actions/object/metadata.go:190

			Key:   call.Arguments[0].Export().(string),
			Value: call.Arguments[1],
			value: value,
		})
	return nil
}

// AppendMetadataRawFunc appends a metadata entry storing the value as raw bytes
// without JSON encoding. In contrast to [MetadataList.AppendMetadataFunc], a string
// is stored as its plain UTF-8 bytes (e.g. `de` instead of `"de"`).
// Allowed values are strings and byte arrays (Uint8Array or an array of integers 0-255).
func (md *MetadataList) AppendMetadataRawFunc(call goja.FunctionCall) goja.Value {
	if len(call.Arguments) != 2 {
		panic("exactly 2 (key, value) arguments expected")
	}

	value := rawMetadataValue(call.Arguments[1].Export())
	if len(value) == 0 {
		panic("value must not be empty")
	}

	md.metadata = append(md.metadata,
		&Metadata{
			Key:   call.Arguments[0].Export().(string),
			Value: call.Arguments[1],
			value: value,
		})
	return nil
}

// rawMetadataValue converts an exported goja value to raw bytes.
// Strings are converted to their UTF-8 bytes, Uint8Array is exported as []byte directly
// and plain arrays must only contain integers in the range 0-255.
func rawMetadataValue(v interface{}) []byte {
	switch value := v.(type) {
	case string:
		return []byte(value)

View on GitHub (pinned to 13948f2bcd)

Solutions

  1. Pass a non-empty string or a byte array with at least one element
  2. Check the source variable in the action for empty/undefined values before calling
  3. Remove the metadata entry instead of setting an empty value if that was the intent

Example fix

// before
const lang = i18n.detect(); // may be ''
metadata.appendMetadataRaw('lang', lang);
// after
if (lang) { metadata.appendMetadataRaw('lang', lang); }
Defensive patterns

Strategy: validation

Validate before calling

if (!value || (Array.isArray(value) && value.length === 0)) throw new Error('metadata value required');

Type guard

function isNonEmptyRawValue(v){ return (typeof v === 'string' && v.length > 0) || (Array.isArray(v) && v.length > 0); }

Try / catch

try { metadata.appendMetadataRaw(key, value); } catch (e) { if (/empty/.test(String(e))) { value = fallbackValue; metadata.appendMetadataRaw(key, value); } }

Prevention

When it happens

Trigger: A JS action calls appendMetadataRaw(key, '') with an empty string, or with an empty array / array of values that normalize to zero bytes.

Common situations: Dynamic value built from an empty variable; translation/localization lookup returning empty string; script passing undefined which exports to an empty raw value.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of zitadel/zitadel@13948f2bcd (2026-09-06). Data as JSON: /api/errors/de0acd38461633f1. Report an issue: GitHub.