Skip to content

Commit dc6f777

Browse files
authored
doctor: don't error on schema id 0 missing from summary section (#1453)
### Changelog Fixed a bug in `mcap doctor` which would raise an error for schemaless channels. ### Docs None ### Description Previously a schemaless channel would result in errors like: ``` Indexed chunk at offset 42 contains messages referencing schema (0) not duplicated in summary section ```
1 parent 892748a commit dc6f777

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

go/cli/mcap/cmd/doctor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ func (doctor *mcapDoctor) Examine() Diagnosis {
567567
// message with unknown channel, this is checked when that message is scanned
568568
continue
569569
}
570+
if channel.SchemaID == 0 {
571+
continue
572+
}
570573
if present := doctor.schemaIDsInSummarySection[channel.SchemaID]; !present {
571574
doctor.error(
572575
"Indexed chunk at offset %d contains messages referencing schema (%d) not duplicated in summary section",

go/cli/mcap/cmd/doctor_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,35 @@ func TestPassesIndexedMessagesWithRepeatedSchemas(t *testing.T) {
6464
diagnosis := doctor.Examine()
6565
assert.Empty(t, diagnosis.Errors)
6666
}
67+
68+
func TestNoErrorOnSchemalessMessages(t *testing.T) {
69+
buf := bytes.Buffer{}
70+
writer, err := mcap.NewWriter(&buf, &mcap.WriterOptions{
71+
Chunked: true,
72+
ChunkSize: 10,
73+
})
74+
require.NoError(t, err)
75+
require.NoError(t, writer.WriteHeader(&mcap.Header{
76+
Profile: "",
77+
Library: "",
78+
}))
79+
require.NoError(t, writer.WriteChannel(&mcap.Channel{
80+
ID: 1,
81+
SchemaID: 0,
82+
Topic: "schemaless_topic",
83+
}))
84+
require.NoError(t, writer.WriteMessage(&mcap.Message{
85+
ChannelID: 1,
86+
Sequence: 0,
87+
LogTime: 0,
88+
PublishTime: 0,
89+
Data: []byte{0, 1, 2},
90+
}))
91+
require.NoError(t, writer.Close())
92+
93+
rs := bytes.NewReader(buf.Bytes())
94+
95+
doctor := newMcapDoctor(rs)
96+
diagnosis := doctor.Examine()
97+
assert.Empty(t, diagnosis.Errors)
98+
}

0 commit comments

Comments
 (0)