@cryptotaxi247 / kubo / commits / 56b22d79d

fix(rpc/pin): return error if listing an invalid, but known, pin type (#11238)

* fix(core/commands/pin): return error if listing an invalid, but known, pin type * test: add cli test for pin ls with known but non-listable type Covers the case where --type=internal passes boxo's StringToMode validation but is rejected by options.Pin.Ls.Type, which previously caused a panic instead of returning an error. --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>

Adin Schmahmann committed Mar 17, 2026 at 12:32 UTC 56b22d79d29f926ca7f59493488655a7d1511cf5
2 files changed +12 -1
core/commands/pin/pin.go
+1 -1
@@ -570,7 +570,7 @@ func pinLsAll(req *cmds.Request, typeStr string, detailed bool, name string, api
570
571 opt, err := options.Pin.Ls.Type(typeStr)
572 if err != nil {
573 - panic("unhandled pin type")
573 + return err
574 }
575
576 pins := make(chan coreiface.Pin)
test/cli/pin_ls_names_test.go
+11
@@ -509,6 +509,17 @@ func TestPinLsEdgeCases(t *testing.T) {
509 require.Contains(t, res.Stderr.String(), "must be one of {direct, indirect, recursive, all}")
510 })
511
512 + t.Run("known but non-listable pin type returns error", func(t *testing.T) {
513 + t.Parallel()
514 + node := setupTestNode(t)
515 +
516 + // "internal" is a valid pin.Mode in boxo but not a valid --type for pin ls.
517 + // Before the fix, this caused a panic instead of returning an error.
518 + res := node.RunIPFS("pin", "ls", "--type=internal")
519 + require.NotEqual(t, 0, res.ExitCode())
520 + require.Contains(t, res.Stderr.String(), "invalid type 'internal'")
521 + })
522 +
523 t.Run("non-existent path returns proper error", func(t *testing.T) {
524 t.Parallel()
525 node := setupTestNode(t)