Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from nil MXC argument to ement--media-request #315

Open
phil-s opened this issue Oct 26, 2024 · 2 comments
Open

Error from nil MXC argument to ement--media-request #315

phil-s opened this issue Oct 26, 2024 · 2 comments
Assignees
Labels
bug Something isn't working priority:B

Comments

@phil-s
Copy link

phil-s commented Oct 26, 2024

I encountered this just now:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("mxc://\\([^/]+\\)/\\([^z-a]+\\)" nil)
  ement--mxc-to-endpoint(nil)
  ement--media-request(nil #s(ement-session ...) :then #f(...) :else #f(...) :queue #s(plz-queue ...) :authenticatedp t)
  ement-room--image-download(...)
  ement-room--format-m.image(...)

In a bit more detail:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("mxc://\\([^/]+\\)/\\([^z-a]+\\)" nil)
  ement--mxc-to-endpoint(nil)
  ement--media-request(nil #s(ement-session :user ... :server ... :token "..." :transaction-id 2562682986 :rooms ... :next-batch "s5356622809_757284974_17004110_3197373295_3474708229_261644646_1399661551_11030818304_0_360008" :device-id nil :initial-device-display-name nil :has-synced-p t :account-data ... :events #<hash-table equal 3729/6144 0x1e48b9de51f8 ...>) :then #f(compiled-function (&rest args2) #<bytecode -0x57dd47ee68ade1c>) :else #f(compiled-function (plz-error) "Handle PLZ-ERROR for a failed request to download an image." #<bytecode -0x25c6aed1139c286>) :queue #s(plz-queue :limit 5 :active nil :requests nil :canceled-p nil :first-active nil :last-active nil :first-request nil :last-request nil :finally nil) :authenticatedp t)
  ement-room--image-download(#s(ement-event :id "$RGFAXsXzE8GNS8rePT0mKwMhA9Fp4zwF2xDwSMeeFQY" :sender ... :content ... :origin-server-ts 1729344217155 :type "m.room.message" :unsigned ... :state-key nil :receipts nil :local nil) #s(ement-session :user ... :server ... :token "..." :transaction-id 2562682986 :rooms ... :next-batch "s5356622809_757284974_17004110_3197373295_3474708229_261644646_1399661551_11030818304_0_360008" :device-id nil :initial-device-display-name nil :has-synced-p t :account-data ... :events #<hash-table equal 3729/6144 0x1e48b9de51f8 ...>) :then #f(compiled-function (&rest args2) #<bytecode -0x57dd47ee68ade1c>) :else #f(compiled-function (plz-error) "Handle PLZ-ERROR for a failed request to download an image." #<bytecode -0x25c6aed1139c286>))
  ement-room--format-m.image(#s(ement-event :id "$RGFAXsXzE8GNS8rePT0mKwMhA9Fp4zwF2xDwSMeeFQY" :sender ... :content ... :origin-server-ts 1729344217155 :type "m.room.message" :unsigned ... :state-key nil :receipts nil :local nil) #s(ement-session :user ... :server ... :token "..." :transaction-id 2562682986 :rooms ... :next-batch "s5356622809_757284974_17004110_3197373295_3474708229_261644646_1399661551_11030818304_0_360008" :device-id nil :initial-device-display-name nil :has-synced-p t :account-data ... :events #<hash-table equal 3729/6144 0x1e48b9de51f8 ...>))

This was from the #emacs:matrix.org room, so you might be able to replicate it. I get the error every time I kill the room buffer and then revisit that room. My current session has history for that room back to 2024-09-27 (Friday).

In addition I was seeing (ement-api-error "404: Event not found.") which may be the reason behind the initial error.

I tried the following code change, after which I only get the 404 error.

modified   ement-room.el
@@ -5706,8 +5706,9 @@ ement-room--image-download
   (declare (indent defun))
   (pcase-let* (((cl-struct ement-event content) event)
                ((map ('url mxc)) content))
-    (ement--media-request mxc session :then then :else else
-      :queue ement-images-queue :authenticatedp authenticatedp)))
+    (when mxc
+      (ement--media-request mxc session :then then :else else
+        :queue ement-images-queue :authenticatedp authenticatedp))))
 
 (defun ement-room--format-m.image (event session)
   "Return \"m.image\" EVENT on SESSION formatted as a string.
@phil-s
Copy link
Author

phil-s commented Oct 26, 2024

(pp-eval-expression '(gethash "$RGFAXsXzE8GNS8rePT0mKwMhA9Fp4zwF2xDwSMeeFQY" (ement-session-events ement-session))):

#s(ement-event "$RGFAXsXzE8GNS8rePT0mKwMhA9Fp4zwF2xDwSMeeFQY"
	       #s(ement-user "@tusharhero:envs.net" "tusharhero" nil
			     "#5640d4" nil nil nil nil)
	       ((body . "JPEG_20241019_185233_3350740080818014340.jpg")
		(file
		 (hashes
		  (sha256
		   . "E8Fw3zmAlHy4RiLrU2V8Z2C4U/YgNlu9ethieYs3CIQ"))
		 (iv . "wU8P9278r9WhMmpCjOp/Sg")
		 (key (alg . "A256CTR") (ext . t)
		      (k
		       . "Coe7KTfTEboqUrGwy4YuSuzq5GX20ptzfJbg9tyUhBk")
		      (key_ops . ["encrypt" "decrypt"]) (kty . "oct"))
		 (mimetype . "image/jpeg")
		 (url
		  . "mxc://envs.net/4feae4c2af59b8875dcf8cc463a389c73207ec3e1847629421142343680")
		 (v . "v2"))
		(filename
		 . "JPEG_20241019_185233_3350740080818014340.jpg")
		(info (h . 1600) (mimetype . "image/jpeg")
		      (size . 56749)
		      (thumbnail_file
		       (hashes
			(sha256
			 . "SEd2oZC9d6/mmQuQNND20jreVkdwt6nDsZ3cljKtg8E"))
		       (iv . "oHEmOq+17t0nI0U8rxYimQ")
		       (key (alg . "A256CTR") (ext . t)
			    (k
			     . "sqKMoVDV-Z4RzTLbGJyRfMFC8QsAHVaDIaUHWZOK6lE")
			    (key_ops . ["encrypt" "decrypt"])
			    (kty . "oct"))
		       (mimetype . "image/jpeg")
		       (url
			. "mxc://envs.net/db05a0be5145424afe4166510d813e79149cb7991847629422476132352")
		       (v . "v2"))
		      (thumbnail_info (h . 800)
				      (mimetype . "image/jpeg")
				      (size . 19692) (w . 369)
				      (xyz.amorgan.blurhash
				       . "K33bgoxuWBxut7Rj~qxuWB"))
		      (w . 738)
		      (xyz.amorgan.blurhash . "K33uo}xuWB%2xaRj~qxuWB"))
		(msgtype . "m.image"))
	       1729344217155 "m.room.message" ((membership . "join"))
	       nil nil nil)

@alphapapa alphapapa self-assigned this Oct 26, 2024
@alphapapa alphapapa added bug Something isn't working priority:B labels Oct 26, 2024
@alphapapa
Copy link
Owner

alphapapa commented Oct 26, 2024

Thanks, Phil. Probably just need to adjust the ELSE handler to allow 404s and other HTTP errors to be handled by displaying an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:B
Projects
None yet
Development

No branches or pull requests

2 participants