memos/server/router/api/v1
Steven 65a19df4be fix(backend): correct generic type parameter in withHeaderCarrier helper
Problem:
The withHeaderCarrier generic function had a type mismatch that caused compilation
errors in CI. The function used `T proto.Message` constraint, but Connect's Response
type expects the non-pointer message type while protobuf methods return pointers.

Error from CI:
  type T of resp does not match *T (cannot infer T)

This occurred because:
- Connect methods expect: *connect.Response[v1pb.CreateSessionResponse]
- Service methods return: (*v1pb.CreateSessionResponse, error)
- Old signature: fn func(context.Context) (T, error) with T proto.Message
- This caused T to be inferred as *v1pb.CreateSessionResponse
- Leading to return type: *connect.Response[*v1pb.CreateSessionResponse] (wrong!)

Solution:
Changed generic signature to explicitly handle the pointer/non-pointer distinction:
- New signature: fn func(context.Context) (*T, error) with T any
- T is now the non-pointer type (e.g., v1pb.CreateSessionResponse)
- fn returns *T (e.g., *v1pb.CreateSessionResponse)
- Return type is correctly: *connect.Response[T] (e.g., *connect.Response[v1pb.CreateSessionResponse])

Also removed unused "google.golang.org/protobuf/proto" import and improved documentation
to clarify the T vs *T distinction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 08:06:13 +08:00
..
test refactor: migrate to connect-rpc (#5338) 2025-12-11 19:49:07 +08:00
acl.go fix(backend): implement protocol-agnostic header setting for dual gRPC/Connect-RPC support 2025-12-12 07:46:28 +08:00
acl_config.go refactor: migrate to connect-rpc (#5338) 2025-12-11 19:49:07 +08:00
activity_service.go chore: fix linter 2025-10-31 08:36:12 +08:00
attachment_service.go chore: fix some typos in comments (#5332) 2025-12-11 07:50:16 +08:00
auth_service.go fix(backend): implement protocol-agnostic header setting for dual gRPC/Connect-RPC support 2025-12-12 07:46:28 +08:00
auth_service_client_info_test.go chore: fix linter 2025-08-31 20:22:32 +08:00
common.go refactor: remove unused constants 2025-10-16 20:40:46 +08:00
connect_handler.go refactor: migrate to connect-rpc (#5338) 2025-12-11 19:49:07 +08:00
connect_interceptors.go fix(backend): implement protocol-agnostic header setting for dual gRPC/Connect-RPC support 2025-12-12 07:46:28 +08:00
connect_services.go fix(backend): correct generic type parameter in withHeaderCarrier helper 2025-12-12 08:06:13 +08:00
header_carrier.go fix(backend): correct generic type parameter in withHeaderCarrier helper 2025-12-12 08:06:13 +08:00
health_service.go refactor(store): remove deprecated migration_history table and backward compatibility code 2025-12-01 22:54:30 +08:00
idp_service.go fix(security): add missing authorization checks to various services (#5217) 2025-11-06 19:42:44 +08:00
instance_service.go refactor: simplify theme/locale to user preferences and improve initialization 2025-12-02 09:08:46 +08:00
logger_interceptor.go chore: add a new LOG_STACKTRACES option (#4973) 2025-08-07 23:56:21 +08:00
memo_attachment_service.go fix(security): implement security review recommendations (#5228) 2025-11-06 23:32:27 +08:00
memo_relation_service.go fix(security): implement security review recommendations (#5228) 2025-11-06 23:32:27 +08:00
memo_service.go fix(api): implement custom memo ID support in CreateMemo (#5234) 2025-11-08 09:43:10 +08:00
memo_service_converter.go refactor: rename workspace to instance throughout codebase 2025-11-05 23:35:35 +08:00
memo_service_filter.go refactor: deprecate old filter 2025-07-22 21:25:57 +08:00
reaction_service.go fix(security): implement security review recommendations (#5228) 2025-11-06 23:32:27 +08:00
resource_name.go refactor: rename workspace to instance throughout codebase 2025-11-05 23:35:35 +08:00
shortcut_service.go refactor: remove unused constants 2025-10-16 20:40:46 +08:00
user_service.go refactor: migrate to connect-rpc (#5338) 2025-12-11 19:49:07 +08:00
user_service_stats.go fix: implement tag suggestions functionality 2025-11-08 09:15:38 +08:00
v1.go refactor: migrate to connect-rpc (#5338) 2025-12-11 19:49:07 +08:00