larksuite/cli · error

L1: _meta must not be nil

Error message

L1: _meta must not be nil

What it means

This L1 error means the envelope's Meta field is nil. Meta carries required metadata such as envelope_version and risk/access-token policy; without it the lint cannot continue, so it emits this error and returns immediately, skipping all meta-dependent checks (envelope_version, risk, access tokens).

Source

Thrown at internal/schema/lint.go:54

	if env.InputSchema == nil {
		errs = append(errs, errors.New("L1: inputSchema must not be nil"))
	} else {
		if env.InputSchema.Type != "object" {
			errs = append(errs, fmt.Errorf("L1: inputSchema.type = %q, want \"object\"", env.InputSchema.Type))
		}
		if env.InputSchema.Properties == nil {
			errs = append(errs, errors.New("L1: inputSchema.properties must not be nil"))
		}
	}
	if env.OutputSchema == nil {
		errs = append(errs, errors.New("L1: outputSchema must not be nil"))
	} else {
		if env.OutputSchema.Type != "object" {
			errs = append(errs, fmt.Errorf("L1: outputSchema.type = %q, want \"object\"", env.OutputSchema.Type))
		}
	}
	if env.Meta == nil {
		errs = append(errs, errors.New("L1: _meta must not be nil"))
		// Cannot continue meta-dependent checks
		return errs
	}
	if env.Meta.EnvelopeVersion != "1.0" {
		errs = append(errs, fmt.Errorf("L1: _meta.envelope_version = %q, want \"1.0\"", env.Meta.EnvelopeVersion))
	}

	// L1: validate every Property type recursively
	if env.InputSchema != nil && env.InputSchema.Properties != nil {
		validatePropertyTypes(env.InputSchema.Properties, &errs)
	}
	if env.OutputSchema != nil && env.OutputSchema.Properties != nil {
		validatePropertyTypes(env.OutputSchema.Properties, &errs)
	}

	// ---- L2: type-level consistency ----
	if env.InputSchema != nil && env.InputSchema.Properties != nil {
		// Walk the whole property tree so format/min-max checks reach leaf

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Set Meta to a value with EnvelopeVersion "1.0", a Risk level, and non-empty AccessTokens.
  2. Copy the Meta block from a known-good envelope in the same registry and adjust risk/tokens.
  3. Re-run the lint to surface any subsequent L1/L3 findings that were previously skipped by the early return.

Example fix

// before
env := Envelope{Name: "send.message", InputSchema: in, OutputSchema: out}
// after
env := Envelope{Name: "send.message", InputSchema: in, OutputSchema: out, Meta: &Meta{EnvelopeVersion: "1.0", Risk: core.RiskSafeRead, AccessTokens: []string{"user"}}}
Defensive patterns

Strategy: validation

Validate before calling

func validateMeta(env *Envelope) error {
    if env.Meta == nil {
        return errors.New("envelope requires _meta with envelope_version, risk, access_tokens")
    }
    return nil
}

Type guard

if env.Meta == nil {
    // handle: metadata missing; cannot run meta-dependent checks
}

Try / catch

if err := lintEnvelope(env); err != nil {
    // detect "_meta must not be nil" and populate Meta before retrying lint
}

Prevention

When it happens

Trigger: Linting an Envelope constructed without Meta, or with a zero-value Meta pointer; also triggered by decode paths that drop the _meta block.

Common situations: Hand-written envelopes omitting _meta; plugin authors copying struct literals without the meta block; deserialization where the "_meta" JSON key was absent so Meta decodes to nil.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/0296423ccd4261f8. Report an issue: GitHub.