@cryptotaxi247 / kubo / commits / 7a50636f9

fix: return an error when an unknown object type is passed

fixes #7785

Steven Allen committed Nov 30, 2020 at 17:47 UTC 7a50636f9a478ac1a9c14f9d12a8e8c8f7c0e0eb
2 files changed +6
core/coreapi/object.go
+2
@@ -48,6 +48,8 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
48 n = new(dag.ProtoNode)
49 case "unixfs-dir":
50 n = ft.EmptyDirNode()
51 + default:
52 + return nil, fmt.Errorf("unknown node type: %s", options.Type)
53 }
54
55 err = api.dag.Add(ctx, n)
test/sharness/t0051-object.sh
+4
@@ -223,6 +223,10 @@ test_object_cmd() {
223 ipfs object stat $OUTPUT
224 '
225
226 + test_expect_success "'ipfs object new foo' shouldn't crash" '
227 + test_expect_code 1 ipfs object new foo
228 + '
229 +
230 test_expect_success "'ipfs object links' gives the correct results" '
231 echo "$EMPTY_DIR" 4 foo > expected &&
232 ipfs object links "$OUTPUT" > actual &&