Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all type assertion are checked #2768

Open
2 tasks
Tracked by #2971
amyangfei opened this issue Sep 8, 2021 · 1 comment
Open
2 tasks
Tracked by #2971

Ensure all type assertion are checked #2768

amyangfei opened this issue Sep 8, 2021 · 1 comment
Assignees
Labels
subject/new-feature Denotes an issue or pull request adding a new feature.

Comments

@amyangfei
Copy link
Contributor

amyangfei commented Sep 8, 2021

Feature Request

Is your feature request related to a problem? Please describe:

such as the bug in #2758, type assertion without any check can lead to unexpected panic

Describe the feature you'd like:

  • Ensure all type assertion is checked, we found many type assertions in codec module.
  • Investigate whether there is any lint way to detect unchecked type assertion.
cdc/sink/codec/avro.go:397:             str := col.Value.(string)
cdc/sink/codec/avro.go:429:             str := col.Value.(string)
cdc/sink/codec/avro.go:475:             return col.Value.(int64), "long", nil
cdc/sink/codec/avro.go:477:             return col.Value.(tijson.BinaryJSON).String(), "string", nil
cdc/sink/codec/avro.go:479:             return col.Value.(string), "string", nil
cdc/sink/codec/avro.go:488:                     return int32(col.Value.(uint64)), "int", nil
cdc/sink/codec/avro.go:490:             return int32(col.Value.(int64)), "int", nil
cdc/sink/codec/avro.go:493:                     return int64(col.Value.(uint64)), "long", nil
cdc/sink/codec/avro.go:495:             return col.Value.(int64), "int", nil
cdc/sink/codec/avro.go:500:             return col.Value.(int64), "long", nil
cdc/sink/codec/avro.go:502:             return col.Value.(float64), "float", nil
cdc/sink/codec/maxwell.go:105:                                  value.Old[v.Name] = string(v.Value.([]byte))
cdc/sink/codec/maxwell.go:120:                                  value.Data[v.Name] = string(v.Value.([]byte))
cdc/sink/codec/maxwell.go:142:                                          if value.Data[v.Name] != string(v.Value.([]byte)) {
cdc/sink/codec/maxwell.go:143:                                                  value.Old[v.Name] = string(v.Value.([]byte))
cdc/sink/codec/json.go:67:              str := string(col.Value.([]byte))
cdc/sink/codec/json.go:89:              str := col.Value.(string)
cdc/sink/producer/kafka/kafka.go:251:                   flushedOffset := msg.Metadata.(uint64)
cdc/sink/common/flow_control.go:209:            if peeked := c.queue.Front().(*commitTsSizeEntry); peeked.CommitTs <= resolvedTs {
cdc/model/reactor_state.go:298:         return fn(e.(*ChangeFeedInfo))
cdc/model/reactor_state.go:313:         return fn(e.(*ChangeFeedStatus))
cdc/model/reactor_state.go:329:         return fn(e.(*TaskPosition))
cdc/model/reactor_state.go:345:         return fn(e.(*TaskStatus))
cdc/model/reactor_state.go:361:         return fn(*e.(*TaskWorkload))
cdc/entry/mounter.go:280:       k := meta.(metaListData)
cdc/processor/manager.go:80:    ctx := stdCtx.(cdcContext.Context)
cdc/processor/manager.go:81:    globalState := state.(*model.GlobalReactorState)
cdc/processor/manager.go:184:           w := cmd.payload.(io.Writer)
@amyangfei amyangfei added the subject/new-feature Denotes an issue or pull request adding a new feature. label Sep 8, 2021
@overvenus
Copy link
Member

@zhaoxinyu PTAL

@zhaoxinyu zhaoxinyu self-assigned this Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subject/new-feature Denotes an issue or pull request adding a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants