{"record":{"id":"b3d880b729dfbad1","repo":"larksuite/cli","slug":"decode-app-versions-response-w","errorCode":null,"errorMessage":"decode app_versions response: %w","messagePattern":"decode app_versions response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/appmeta/app_version.go","lineNumber":58,"sourceCode":"\tvar envelope struct {\n\t\tData struct {\n\t\t\tItems []struct {\n\t\t\t\tVersionID   string          `json:\"version_id\"`\n\t\t\t\tVersion     string          `json:\"version\"`\n\t\t\t\tStatus      int             `json:\"status\"`\n\t\t\t\tPublishTime json.RawMessage `json:\"publish_time\"`\n\t\t\t\tEventInfos  []struct {\n\t\t\t\t\tEventType string `json:\"event_type\"`\n\t\t\t\t} `json:\"event_infos\"`\n\t\t\t\tScopes []struct {\n\t\t\t\t\tScope      string   `json:\"scope\"`\n\t\t\t\t\tTokenTypes []string `json:\"token_types\"`\n\t\t\t\t} `json:\"scopes\"`\n\t\t\t} `json:\"items\"`\n\t\t} `json:\"data\"`\n\t}\n\tif err := json.Unmarshal(raw, &envelope); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode app_versions response: %w\", err)\n\t}\n\n\tfor _, it := range envelope.Data.Items {\n\t\tif it.Status != appVersionStatusPublished || !publishTimeSet(it.PublishTime) {\n\t\t\tcontinue\n\t\t}\n\t\tv := &AppVersion{\n\t\t\tVersionID: it.VersionID,\n\t\t\tVersion:   it.Version,\n\t\t}\n\t\tfor _, e := range it.EventInfos {\n\t\t\tif e.EventType != \"\" {\n\t\t\t\tv.EventTypes = append(v.EventTypes, e.EventType)\n\t\t\t}\n\t\t}\n\t\tfor _, s := range it.Scopes {\n\t\t\tif s.Scope != \"\" && containsString(s.TokenTypes, \"tenant\") {\n\t\t\t\tv.TenantScopes = append(v.TenantScopes, s.Scope)","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/appmeta/app_version.go#L40-L76","documentation":"FetchCurrentPublished in internal/appmeta fetches the app_versions list and unmarshals the response into a typed envelope before selecting the latest published version. This error wraps any json.Unmarshal failure decoding the app_versions response, preserving the cause.","triggerScenarios":"The app_versions endpoint returns a body that fails to unmarshal: invalid JSON, or items/scopes fields whose JSON types differ from the envelope (e.g. token_types as object instead of array).","commonSituations":"Gateway/auth errors returning non-JSON bodies; API schema drift on app_versions; truncated responses over flaky networks.","solutions":["Inspect the wrapped json error to identify the failing field or syntax position","Dump the raw body of the failed response for comparison with the expected envelope","Verify the response is actually from the app_versions endpoint and not an error page","Update the CLI if the Feishu app_versions API shape changed"],"exampleFix":"// before\nitems, err := meta.FetchCurrentPublished(ctx, raw)\n// after (diagnose decode)\nif err != nil { log.Printf(\"decode: %v; body: %s\", err, raw) }","handlingStrategy":"try-catch","validationCode":"if !json.Valid(raw) { return fmt.Errorf(\"app_versions response is not valid JSON\") }","typeGuard":null,"tryCatchPattern":"v, err := meta.FetchCurrentPublished(ctx, raw)\nif err != nil {\n  var typeErr *json.UnmarshalTypeError\n  if errors.As(err, &typeErr) { log.Printf(\"field %s: %v\", typeErr.Field, typeErr) }\n  return err\n}","preventionTips":["Assert envelope shape with unit-test fixtures mirroring the live API","Fail fast on non-2xx/non-JSON gateway responses","Capture raw bodies for debugging production decode errors","Track Feishu app_versions API changes when upgrading"],"tags":["json","decode","api","appmeta"],"backgroundTag":"json-response-decode-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"}