Commit 7a50636f authored by Steven Allen's avatar Steven Allen

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

fixes #7785
parent 1bf8a723
......@@ -48,6 +48,8 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
n = new(dag.ProtoNode)
case "unixfs-dir":
n = ft.EmptyDirNode()
default:
return nil, fmt.Errorf("unknown node type: %s", options.Type)
}
err = api.dag.Add(ctx, n)
......
......@@ -223,6 +223,10 @@ test_object_cmd() {
ipfs object stat $OUTPUT
'
test_expect_success "'ipfs object new foo' shouldn't crash" '
test_expect_code 1 ipfs object new foo
'
test_expect_success "'ipfs object links' gives the correct results" '
echo "$EMPTY_DIR" 4 foo > expected &&
ipfs object links "$OUTPUT" > actual &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment