fix(sling): accept bead IDs directly even when routing fails
When routing-based verification (verifyBeadExists) fails due to routes.jsonl configuration issues, gt sling now falls back to pattern matching via looksLikeBeadID to accept valid bead ID formats. The fix ensures: 1. verifyBeadExists is tried first (routing-based lookup) 2. verifyFormulaExists is tried second (formula check) 3. looksLikeBeadID pattern match is used as final fallback Also improved looksLikeBeadID to accept any 1-5 letter lowercase prefix followed by hyphen and alphanumeric chars. Fixes: gt sling bd-xxx failing with "not a valid bead or formula" when the bead exists but routing cannot find it. Closes: gt-9e8s5 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -210,16 +210,23 @@ func runSling(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// Try as bead first
|
||||
if err := verifyBeadExists(firstArg); err == nil {
|
||||
// It's a bead
|
||||
// It's a verified bead
|
||||
beadID = firstArg
|
||||
} else {
|
||||
// Not a bead - try as standalone formula
|
||||
// Not a verified bead - try as standalone formula
|
||||
if err := verifyFormulaExists(firstArg); err == nil {
|
||||
// Standalone formula mode: gt sling <formula> [target]
|
||||
return runSlingFormula(args)
|
||||
}
|
||||
// Neither bead nor formula
|
||||
return fmt.Errorf("'%s' is not a valid bead or formula", firstArg)
|
||||
// Not a formula either - check if it looks like a bead ID (routing issue workaround).
|
||||
// Accept it and let the actual bd update fail later if the bead doesn't exist.
|
||||
// This fixes: gt sling bd-ka761 beads/crew/dave failing with 'not a valid bead or formula'
|
||||
if looksLikeBeadID(firstArg) {
|
||||
beadID = firstArg
|
||||
} else {
|
||||
// Neither bead nor formula
|
||||
return fmt.Errorf("'%s' is not a valid bead or formula", firstArg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user