diff --git a/core/commands/add.go b/core/commands/add.go
index 9f686e14b9f449acce3529baaba308bbce3add3f..12a38aaebe78a7bcf2521e58883daa6c83fca7eb 100644
--- a/core/commands/add.go
+++ b/core/commands/add.go
@@ -210,6 +210,9 @@ See 'dag export' and 'dag import' for more information.
 		if !ok {
 			return fmt.Errorf("unrecognized hash function: %q", strings.ToLower(hashFunStr))
 		}
+		if _, err := mh.GetHasher(hashFunCode); err != nil {
+			return err
+		}
 
 		enc, err := cmdenv.GetCidEncoder(req)
 		if err != nil {
diff --git a/test/sharness/t0042-add-skip.sh b/test/sharness/t0042-add-skip.sh
index 9da78163c4534e064ee12ce9b1176cfec98379cf..64d8e1a7c41628d8874301939d37062d6d4097ce 100755
--- a/test/sharness/t0042-add-skip.sh
+++ b/test/sharness/t0042-add-skip.sh
@@ -93,6 +93,10 @@ EOF
     test_cmp expected actual
   '
 
+  test_expect_failure "'ipfs add' with an unregistered hash and wrapped leaves fails without crashing" '
+    ipfs add --hash poseidon-bls12_381-a2-fc1 --raw-leaves=false -r mountdir/planets
+  '
+
 }
 
 # should work offline