xach / zs3

Work with Amazon S3 and Amazon CloudFront from Common Lisp

Home Page:http://www.xach.com/lisp/zs3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type-error when calling delete-objects

orthecreedence opened this issue · comments

I'm using Clozure Common Lisp Version 1.8-r15286M, with a fresh (ql:update-all-dists).

My creds are set fine and I can do other operations fine (like listing keys). When I do (zs3:delete-objects "mybucket.musio.com" '("test" "keys")) I get:

value #(60 63 120 109 108 32 118 101 114 115 105 111 110 61 34
        49 46 48 34 32 101 110 99 111 100 105 110 103 61 34 85
        84 70 45 56 34 63 62 10 60 68 101 108 101 116 101 62 60
        79 98 106 101 99 116 62 60 75 101 121 62 116 101 115 116
        60 47 75 101 121 62 60 47 79 98 106 101 99 116 62 60 79
        98 106 101 99 116 62 60 75 101 121 62 107 101 121 115 60
        47 75 101 121 62 60 47 79 98 106 101 99 116 62 60 47 68
        101 108 101 116 101
        62) is not of the expected type (SIMPLE-ARRAY
                                         (UNSIGNED-BYTE 8)
                                         (*)).
   [Condition of type TYPE-ERROR]

Backtrace:
  0: (#<STANDARD-METHOD IRONCLAD:UPDATE-DIGEST (IRONCLAD:MD5 VECTOR)> #S(IRONCLAD:MD5 :AMOUNT 0 :BUFFER #(0 0 0 0 0 0 ...) :BUFFER-INDEX ...) #(60 63 120 109 108 32 ...) :START 0 :END 120)
  1: (#<STANDARD-METHOD IRONCLAD:DIGEST-SEQUENCE (T T)> #S(IRONCLAD:MD5 :AMOUNT 0 :BUFFER #(0 0 0 0 0 0 ...) :BUFFER-INDEX ...) #(60 63 120 109 108 32 ...) :START 0 :END NIL :DIGEST NIL :DIGEST-START 0)
  2: (CCL::%%CHECK-KEYWORDS #(2 #(:DIGEST-START :DIGEST :END :START) #<CCL:METHOD-FUNCTION IRONCLAD:DIGEST-SEQUENCE (T T)>) 17591605212383)
  3: (NIL #<Unknown Arguments>)
  4: (ZS3::VECTOR-MD5/B64 #(60 63 120 109 108 32 ...))
  5: ((:INTERNAL ZS3::BULK-DELETE ZS3:DELETE-OBJECTS) ("test" "keys"))
  6: (ZS3:DELETE-OBJECTS "mybucket.musio.com" ("test" "keys") :CREDENTIALS ("MY" "CREDS"))
  7: (CCL::CALL-CHECK-REGS ZS3:DELETE-OBJECTS "mybucket.musio.com" ("test" "keys"))
  8: (CCL::CHEAP-EVAL (ZS3:DELETE-OBJECTS "mybucket.musio.com" '("test" "keys")))

If I run, (zs3::vector-md5/b64 #(60 63 120 109 108 32 ...)) I get the same error, but
(zs3:vector-md5/b64 (coerce #(60 63 120 109 108 32 ...) '(simple-array (unsigned-byte 8)))) it generates the checksum fine.

I tried to find any instance of vector-md5/b64 in all my quicklisp and local asdf libs but it just doesn't exist. Any ideas on how to fix this?

Oh, I should also note that zs3:delete-object works fine, oddly enough. So I'm just looping for now!

Hmm, I don't have that version of CCL. Do you get the same issue with SBCL?

If you do (setf zs3:credentials (list "a" "b")) do you get the same error in CCL?

Same error with/without working credentials, so I think it's happening before the request goes out. I tried with SBCL and it works with no problems (of course).

Thanks for checking! I'll try to figure out what's up.

The fix is to coerce in zs3::bulk-delete-document:

diff --git a/interface.lisp b/interface.lisp
index 027bce1..67618f1 100644
--- a/interface.lisp
+++ b/interface.lisp
@@ -473,14 +473,16 @@ constraint."
                  :key key)))

 (defun bulk-delete-document (keys)
-  (cxml:with-xml-output (cxml:make-octet-vector-sink)
-    (cxml:with-element "Delete"
-      (map nil
-           (lambda (key)
-             (cxml:with-element "Object"
-               (cxml:with-element "Key"
-                 (cxml:text (name key)))))
-           keys))))
+  (coerce
+   (cxml:with-xml-output (cxml:make-octet-vector-sink)
+     (cxml:with-element "Delete"
+       (map nil
+            (lambda (key)
+              (cxml:with-element "Object"
+                (cxml:with-element "Key"
+                  (cxml:text (name key)))))
+            keys)))
+   '(simple-array (unsigned-byte 8) (*))))

 (defbinder delete-objects-result
   ("DeleteResult"

I'll apply this tonight and make a new release very soon.

This worked, thanks!

This fix is now in a released version in Quicklisp.