Skip to content

Commit caca20b

Browse files
author
Moses Narrow
committed
Add Version field to all Entry structs to fix discovery validation
Issue: After implementing fallback discovery client, dmsg utilities still failed with "entry validation error: entry has no version" when posting the local client's entry to HTTP discovery. Root cause: Multiple places create disc.Entry structs without setting the Version field. Discovery API requires Version="0.0.1" for all entries. Fixes: 1. pkg/direct/entries.go - Add Version to GetClientEntry() 2. pkg/direct/client.go - Return ErrKeyNotFound instead of empty Entry 3. internal/cli/cli.go - Add Version to 3 synthetic entries: - Discovery server entry (StartDmsgWithSyntheticDiscovery) - Discovery server entry (StartDmsgWithDirectClient) - Local client entry (StartDmsgWithDirectClient) The direct client now properly returns ErrKeyNotFound for unknown entries, allowing the dmsg client to create a new entry with NewClientEntry() which includes the version field. Test: dmsg curl -Z and dmsg web -Z now work correctly
1 parent 3b4a63e commit caca20b

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

internal/cli/cli.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ func StartDmsgWithSyntheticDiscovery(ctx context.Context, dlog *logging.Logger,
137137
delegatedServers = append(delegatedServers, server.Static)
138138
}
139139
syntheticEntry := &disc.Entry{
140-
Static: discoveryPK,
140+
Version: "0.0.1",
141+
Static: discoveryPK,
141142
Client: &disc.Client{
142143
DelegatedServers: delegatedServers,
143144
},
@@ -310,7 +311,8 @@ func StartDmsgWithDirectClient(ctx context.Context, dlog *logging.Logger, pk cip
310311
delegatedServers = append(delegatedServers, server.Static)
311312
}
312313
discoveryEntry := &disc.Entry{
313-
Static: discoveryPK,
314+
Version: "0.0.1",
315+
Static: discoveryPK,
314316
Client: &disc.Client{
315317
DelegatedServers: delegatedServers,
316318
},
@@ -326,7 +328,8 @@ func StartDmsgWithDirectClient(ctx context.Context, dlog *logging.Logger, pk cip
326328
delegatedServers = append(delegatedServers, server.Static)
327329
}
328330
clientEntry := &disc.Entry{
329-
Static: pk,
331+
Version: "0.0.1",
332+
Static: pk,
330333
Client: &disc.Client{
331334
DelegatedServers: delegatedServers,
332335
},

pkg/direct/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (c *directClient) Entry(_ context.Context, pubKey cipher.PubKey) (*disc.Ent
4141
return entry, nil
4242
}
4343
}
44-
return &disc.Entry{}, nil
44+
return nil, disc.ErrKeyNotFound
4545
}
4646

4747
// PostEntry adds a new Entry to the entries field of directClient.

pkg/direct/entries.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ func GetClientEntry(pks cipher.PubKeys, servers []*disc.Entry) (clients []*disc.
1616

1717
for _, pk := range pks {
1818
client := &disc.Entry{
19-
Static: pk,
19+
Version: "0.0.1",
20+
Static: pk,
2021
Client: &disc.Client{
2122
DelegatedServers: srvPKs,
2223
},

0 commit comments

Comments
 (0)