109
+
const MaxBatchSize = 1000
// GetByDIDs retrieves multiple users by their DIDs in a single query
// Returns a map of DID -> User for efficient lookups
// Missing users are not included in the result map (no error for missing users)
func (r *postgresUserRepo) GetByDIDs(ctx context.Context, dids []string) (map[string]*users.User, error) {
return make(map[string]*users.User), nil
119
+
// Validate batch size to prevent excessive memory usage and query timeouts
120
+
if len(dids) > MaxBatchSize {
121
+
return nil, fmt.Errorf("batch size %d exceeds maximum %d", len(dids), MaxBatchSize)
124
+
// Validate DID format to prevent SQL injection and malformed queries
125
+
// All atProto DIDs must start with "did:" prefix
126
+
for _, did := range dids {
127
+
if !strings.HasPrefix(did, "did:") {
128
+
return nil, fmt.Errorf("invalid DID format: %s", did)
// Build parameterized query with IN clause