Skip to content

Commit ff8ec6b

Browse files
authored
bugfix: handle missing agent instructions gracefully in fetchAgentInstructions (#46)
1 parent a19c4c2 commit ff8ec6b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

trainings/run.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (h *Handlers) Run(ctx context.Context, detached bool) error {
6666
// fetchAgentInstructions asks the server for training-specific agent instructions
6767
// (content for CLAUDE.md / AGENTS.md). Returns nil when the training has none.
6868
// On codes.Unimplemented (old server) it logs a warning and returns nil.
69+
// On codes.NotFound (training has no instructions registered) it silently returns nil.
6970
func (h *Handlers) fetchAgentInstructions(ctx context.Context, trainingRootFs *afero.BasePathFs) ([]byte, error) {
7071
cfg := h.config.TrainingConfig(trainingRootFs)
7172

@@ -74,9 +75,13 @@ func (h *Handlers) fetchAgentInstructions(ctx context.Context, trainingRootFs *a
7475
Token: h.config.GlobalConfig().Token,
7576
})
7677
if err != nil {
77-
if status.Code(err) == codes.Unimplemented {
78+
switch status.Code(err) {
79+
case codes.Unimplemented:
7880
logrus.Warn("Server does not support agent instructions, skipping AI companion setup")
7981
return nil, nil
82+
case codes.NotFound:
83+
// Training has no agent instructions registered — that's fine, they're optional.
84+
return nil, nil
8085
}
8186
return nil, errors.Wrap(err, "fetching agent instructions")
8287
}

0 commit comments

Comments
 (0)