{"record":{"id":"17be8e2e0f2d3662","repo":"chenhg5/cc-connect","slug":"line-invalid-session-key-q","errorCode":null,"errorMessage":"line: invalid session key %q","messagePattern":"line: invalid session key %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/line/line.go","lineNumber":312,"sourceCode":"\t}\n\tvar parts []string\n\trunes := []rune(s)\n\tfor len(runes) > 0 {\n\t\tend := maxLen\n\t\tif end > len(runes) {\n\t\t\tend = len(runes)\n\t\t}\n\t\tparts = append(parts, string(runes[:end]))\n\t\trunes = runes[end:]\n\t}\n\treturn parts\n}\n\nfunc (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {\n\t// line:{targetID} (user or group)\n\tparts := strings.SplitN(sessionKey, \":\", 2)\n\tif len(parts) < 2 || parts[0] != \"line\" {\n\t\treturn nil, fmt.Errorf(\"line: invalid session key %q\", sessionKey)\n\t}\n\treturn replyContext{targetID: parts[1], targetType: \"user\"}, nil\n}\n\nfunc (p *Platform) Stop() error {\n\tif p.server != nil {\n\t\treturn p.server.Shutdown(context.Background())\n\t}\n\treturn nil\n}\n","sourceCodeStart":294,"sourceCodeEnd":323,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/line/line.go#L294-L323","documentation":"ReconstructReplyCtx parses a session key of the form \"line:{targetID}\". If the key has no colon-separated prefix or the prefix is not \"line\", it returns \"line: invalid session key %q\". The library throws it to reject session keys that were not produced by this platform's session-key format.","triggerScenarios":"Calling ReconstructReplyCtx with a sessionKey that lacks the \"line:\" prefix (e.g. \"123456\"), contains no ':' at all, or belongs to another platform (e.g. \"telegram:123\").","commonSituations":"Passing a raw chat/user ID instead of the prefixed session key; storing/reconstructing a session across platform adapters; corrupted or manually edited persisted session records.","solutions":["Ensure the session key passed in is in the \"line:{targetID}\" format","Verify you are calling line.Platform's ReconstructReplyCtx, not another platform's, for LINE keys","Log the offending sessionKey (%q) and fix whatever persisted/generated it"],"exampleFix":"// before\nctx, err := p.ReconstructReplyCtx(\"U1234abcd\")\n// after\nkey := \"line:U1234abcd\"\nif !strings.HasPrefix(key, \"line:\") {\n    key = \"line:\" + key\n}\nctx, err := p.ReconstructReplyCtx(key)","handlingStrategy":"validation","validationCode":"func validLineSessionKey(key string) bool {\n    parts := strings.SplitN(key, \":\", 2)\n    return len(parts) == 2 && parts[0] == \"line\" && parts[1] != \"\"\n}","typeGuard":"null","tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"invalid session key\") {\n        slog.Warn(\"skipping non-LINE session key\", \"key\", key)\n        return\n    }\n    return err\n}","preventionTips":["Always persist session keys in the \"line:{targetID}\" form","Never hand-strip or edit stored session keys","Match the platform adapter to the key prefix before reconstructing","Include the prefix when generating keys from raw channel IDs"],"tags":["line","session-key","parsing","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}