{"record":{"id":"f9fec3f613fc0446","repo":"larksuite/cli","slug":"l1-inputschema-must-not-be-nil","errorCode":null,"errorMessage":"L1: inputSchema must not be nil","messagePattern":"L1: inputSchema must not be nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/schema/lint.go","lineNumber":37,"sourceCode":"\t\"object\":  true,\n}\n\nvar validAccessTokens = map[string]bool{\n\t\"user\": true,\n\t\"bot\":  true,\n}\n\n// lintEnvelope runs L1-L3 checks and returns a list of errors. Empty slice\n// means the envelope is compliant.\nfunc lintEnvelope(env Envelope) []error {\n\tvar errs []error\n\n\t// ---- L1: structural ----\n\tif env.Name == \"\" {\n\t\terrs = append(errs, errors.New(\"L1: name must not be empty\"))\n\t}\n\tif env.InputSchema == nil {\n\t\terrs = append(errs, errors.New(\"L1: inputSchema must not be nil\"))\n\t} else {\n\t\tif env.InputSchema.Type != \"object\" {\n\t\t\terrs = append(errs, fmt.Errorf(\"L1: inputSchema.type = %q, want \\\"object\\\"\", env.InputSchema.Type))\n\t\t}\n\t\tif env.InputSchema.Properties == nil {\n\t\t\terrs = append(errs, errors.New(\"L1: inputSchema.properties must not be nil\"))\n\t\t}\n\t}\n\tif env.OutputSchema == nil {\n\t\terrs = append(errs, errors.New(\"L1: outputSchema must not be nil\"))\n\t} else {\n\t\tif env.OutputSchema.Type != \"object\" {\n\t\t\terrs = append(errs, fmt.Errorf(\"L1: outputSchema.type = %q, want \\\"object\\\"\", env.OutputSchema.Type))\n\t\t}\n\t}\n\tif env.Meta == nil {\n\t\terrs = append(errs, errors.New(\"L1: _meta must not be nil\"))\n\t\t// Cannot continue meta-dependent checks","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/schema/lint.go#L19-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Assign a non-nil InputSchema to the envelope, with Type set to \"object\" and a non-nil Properties map.","If the envelope takes no arguments, declare an explicit empty object schema rather than leaving the field nil.","Run the envelope lint (make quality-gate or the schema lint tests) before committing to catch missing schemas early."],"exampleFix":"// before\nenv := Envelope{Name: \"send.message\"}\n// after\nenv := Envelope{Name: \"send.message\", InputSchema: &Schema{Type: \"object\", Properties: map[string]*Property{}}}","handlingStrategy":"validation","validationCode":"func validateInputSchema(env *Envelope) error {\n    if env.InputSchema == nil {\n        return errors.New(\"envelope must declare a non-nil InputSchema\")\n    }\n    return nil\n}","typeGuard":"if env.InputSchema == nil {\n    // handle: schema missing\n}","tryCatchPattern":"if err := lintEnvelope(env); err != nil {\n    var l1 []error\n    if errors.As(err, &l1) { /* inspect L1 findings */ }\n}","preventionTips":["Always construct envelopes through a helper that sets InputSchema, OutputSchema, and Meta together.","Add the envelope to the TestAllEnvelopesPass lint suite so CI fails on missing schemas.","Keep a shared empty-schema constant instead of hand-writing zero-value Envelopes."],"tags":["go","schema","validation","envelope"],"backgroundTag":"schema-validation-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}