larksuite/cli · error

L1: inputSchema must not be nil

Error message

L1: inputSchema must not be nil

What it means

lintEnvelope in internal/schema/lint.go performs structural (L1) validation of an envelope declaration. It rejects any envelope whose InputSchema is nil because every envelope must declare a well-formed MCP-style input schema of type "object" with properties. When InputSchema is nil, the lint stops schema-dependent sub-checks and records this error.

Source

Thrown at internal/schema/lint.go:37

	"object":  true,
}

var validAccessTokens = map[string]bool{
	"user": true,
	"bot":  true,
}

// lintEnvelope runs L1-L3 checks and returns a list of errors. Empty slice
// means the envelope is compliant.
func lintEnvelope(env Envelope) []error {
	var errs []error

	// ---- L1: structural ----
	if env.Name == "" {
		errs = append(errs, errors.New("L1: name must not be empty"))
	}
	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

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Assign a non-nil InputSchema to the envelope, with Type set to "object" and a non-nil Properties map.
  2. If the envelope takes no arguments, declare an explicit empty object schema rather than leaving the field nil.
  3. Run the envelope lint (make quality-gate or the schema lint tests) before committing to catch missing schemas early.

Example fix

// before
env := Envelope{Name: "send.message"}
// after
env := Envelope{Name: "send.message", InputSchema: &Schema{Type: "object", Properties: map[string]*Property{}}}
Defensive patterns

Strategy: validation

Validate before calling

func validateInputSchema(env *Envelope) error {
    if env.InputSchema == nil {
        return errors.New("envelope must declare a non-nil InputSchema")
    }
    return nil
}

Type guard

if env.InputSchema == nil {
    // handle: schema missing
}

Try / catch

if err := lintEnvelope(env); err != nil {
    var l1 []error
    if errors.As(err, &l1) { /* inspect L1 findings */ }
}

Prevention

When it happens

Trigger: Registering or linting an Envelope struct with InputSchema left unset (nil), e.g. hand-writing an envelope in code or constructing one in tests without assigning an input schema.

Common situations: Developers adding a new envelope forget to fill in the InputSchema field; refactoring moves schema construction elsewhere leaving a zero-value Envelope; test fixtures copied from minimal examples omit the schema.

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/f9fec3f613fc0446. Report an issue: GitHub.