ReferenceResolver.Resolve panics on typed-nil StructuredData with missing parent fields

Đang mở Phù hợp với người mới
#181 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
devtools

Hướng nghiên cứu

Lỗi panic đến từ dataFieldReference.walk trong internal/reference/reference.go, quanh dòng 587, nơi r.data[r.field] được gán trong khi r.data có thể là một opencdc.StructuredData nil có kiểu. Hãy tái hiện bằng đoạn mã bốn dòng trong issue (một record có Payload.After là nil, đang resolve .Payload.After.a.b), sau đó đọc cách walk cấp cao nhất tạo dữ liệu cho một nil không có kiểu. Việc được coi là xong khi trường hợp đó không còn panic nữa, bằng cách cấp phát map hoặc trả về ErrNotResolvable, và có thêm một test hồi quy cạnh các test reference hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

reference.Resolver.Resolve panics with assignment to entry in nil map when the targeted structured data is a typed-nil opencdc.StructuredData and the reference has missing parent fields.

internal/reference/reference.go (v0.8.0, dataFieldReference.walk, line ~587): r.data[r.field] = make(map[string]any) assigns into r.data, which is a nil map when the record's .Key, .Payload.Before or .Payload.After is opencdc.StructuredData(nil) (the walk of the top-level references only creates new data for an untyped nil, not a typed-nil map).

Repro with processor-sdk v0.8.0:

rec := opencdc.Record{Payload: opencdc.Change{After: opencdc.StructuredData(nil)}}
r, _ := sdk.NewReferenceResolver(".Payload.After.a.b")
r.Resolve(&rec) // panic: assignment to entry in nil map

Expected: allocate the map (as it does for a nil Data) or return ErrNotResolvable. Built-in processors run in the engine process with no recover, so a record with typed-nil data crashes Conduit. conduit-commons Record.Clone of conduit-commons#338 keeps typed nil as nil, so this becomes reachable from cloned records once that lands.

Workaround in Conduit's split (ConduitIO/conduit#3154): replace typed nil with an empty map before resolving and recover from the panic.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SvPfP7eL7SskkoptXvAYCH

Ngôn ngữ chính
Go
Star
1
Fork
1
Merge trung bình
11 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ConduitIO/conduit-processor-sdk

Tất cả issue của ConduitIO/conduit-processor-sdk

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.