[GH-ISSUE #526] Something changed since version 24 in data structures #337

Closed
opened 2026-03-15 13:58:35 +03:00 by kerem · 9 comments
Owner

Originally created by @baiomys on GitHub (Jun 23, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/526

Processing email data obtained from WebSockets no longer work in v26

Here is queue:

    data = json.loads(response)
    if data['Type'] == 'new' and max_q_messages > 0 :
         await email_queue.put([lbl, data['Data']])

This is processing:

     msg_rec = email_queue.get_nowait()  
     lbl,data = msg_rec
     await hook_run(pit=_GD['PIT_BY_NAM'][lbl], hook=data)

And this is faulty code since I upgraded to v26

async def hook_run(hook: dict, pit: PitInfo):
    rcpt = hook['To'] + hook['Cc'] + hook['Bcc']

TypeError: can only concatenate list (not "NoneType") to list

Looks like something changed in To, Cc or Bcc

Originally created by @baiomys on GitHub (Jun 23, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/526 Processing email data obtained from WebSockets no longer work in v26 Here is queue: ``` data = json.loads(response) if data['Type'] == 'new' and max_q_messages > 0 : await email_queue.put([lbl, data['Data']]) ``` This is processing: ``` msg_rec = email_queue.get_nowait() lbl,data = msg_rec await hook_run(pit=_GD['PIT_BY_NAM'][lbl], hook=data) ``` And this is faulty code since I upgraded to v26 ``` async def hook_run(hook: dict, pit: PitInfo): rcpt = hook['To'] + hook['Cc'] + hook['Bcc'] ``` **_TypeError: can only concatenate list (not "NoneType") to list_** Looks like something changed in To, Cc or Bcc
kerem 2026-03-15 13:58:35 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@axllent commented on GitHub (Jun 23, 2025):

Just so I'm clear, you had version 1.24.0 and now you have v1.26.2? I'm not aware of any changes that would have altered the websocket data structure, so narrowing down the exact version you were on and the version you updated to is necessary so I can compare the code. Please confirm.

<!-- gh-comment-id:2997701346 --> @axllent commented on GitHub (Jun 23, 2025): Just so I'm clear, you had version 1.24.0 and now you have v1.26.2? I'm not aware of any changes that would have altered the websocket data structure, so narrowing down the exact version you were on and the version you updated to is necessary so I can compare the code. Please confirm.
Author
Owner

@baiomys commented on GitHub (Jun 24, 2025):

working:

image: axllent/mailpit:v1.24.2

not working (updated on sunday):

image: axllent/mailpit:latest

I guess it is v1.26.2 now, used sendtestemail.com to send test messages

<!-- gh-comment-id:2998363565 --> @baiomys commented on GitHub (Jun 24, 2025): working: `image: axllent/mailpit:v1.24.2` not working (updated on sunday): `image: axllent/mailpit:latest` I guess it is v1.26.2 now, used sendtestemail.com to send test messages
Author
Owner

@axllent commented on GitHub (Jun 24, 2025):

From what I can tell, there are no changes at all to any of that message summary data sent via the webhook - with the exception of a new object value called "Username". Everything else should be the exact same as it was before.

What would be helpful is if you could please capture and compare the websocket output (you are processing) from v1.24.2 and latest for the same message - and spot the difference (if there is any). Obviously some fields like the ID would differ, but the address details should be identical.

<!-- gh-comment-id:2998422888 --> @axllent commented on GitHub (Jun 24, 2025): From what I can tell, there are no changes at all to any of that message summary data sent via the webhook - with the exception of a new object value called "Username". Everything else should be the exact same as it was before. What would be helpful is if you could please capture and compare the websocket output (you are processing) from `v1.24.2` and `latest` for the same message - and spot the difference (if there is any). Obviously some fields like the ID would differ, but the address details should be identical.
Author
Owner

@baiomys commented on GitHub (Jun 24, 2025):

Was:

"To": [
      {
        "Name": "",
        "Address": "anytext@2tag.org"
      }
    ],
    "Cc": [],
    "Bcc": [
      {
        "Name": "",
        "Address": "~@bucket.2tag.org"
      }
    ],

Now:

"To": [
    {
      "Name": "",
      "Address": "anytext@2tag.org"
    }
  ],
  "Cc": null,
  "Bcc": [
    {
      "Name": "",
      "Address": "~@bucket.2tag.org"
    }
  ],
<!-- gh-comment-id:2998472495 --> @baiomys commented on GitHub (Jun 24, 2025): Was: ``` "To": [ { "Name": "", "Address": "anytext@2tag.org" } ], "Cc": [], "Bcc": [ { "Name": "", "Address": "~@bucket.2tag.org" } ], ``` Now: ``` "To": [ { "Name": "", "Address": "anytext@2tag.org" } ], "Cc": null, "Bcc": [ { "Name": "", "Address": "~@bucket.2tag.org" } ], ```
Author
Owner

@axllent commented on GitHub (Jun 24, 2025):

Thank you, that helps me a lot and explains it! I will look into this within the next day or two.

<!-- gh-comment-id:2998476865 --> @axllent commented on GitHub (Jun 24, 2025): Thank you, that helps me a lot and explains it! I will look into this within the next day or two.
Author
Owner

@baiomys commented on GitHub (Jun 24, 2025):

Thanks!
I already altered the code just in case. =)
rcpt = (hook.get('To') or []) + (hook.get('Cc') or []) + (hook.get('Bcc') or [])

<!-- gh-comment-id:2998490046 --> @baiomys commented on GitHub (Jun 24, 2025): Thanks! I already altered the code just in case. =) `rcpt = (hook.get('To') or []) + (hook.get('Cc') or []) + (hook.get('Bcc') or [])`
Author
Owner

@axllent commented on GitHub (Jun 24, 2025):

Yes, but this doesn't align with the API docs which say the values return an object, which null is not :) Some languages don't care, others do. It's good to have that check in your code anyway, but I still need to fix this either way...

<!-- gh-comment-id:2998660255 --> @axllent commented on GitHub (Jun 24, 2025): Yes, but this doesn't align with the API docs which say the values return an object, which `null` is not :) Some languages don't care, others do. It's good to have that check in your code anyway, but I still need to fix this either way...
Author
Owner

@axllent commented on GitHub (Jun 24, 2025):

The fix was pretty easy - and it only impacted the websocket data. I've pushed a fix for this in the edge build and it will be included in a new release this weekend 👍

<!-- gh-comment-id:2998887591 --> @axllent commented on GitHub (Jun 24, 2025): The fix was pretty easy - and it only impacted the websocket data. I've pushed a fix for this in the edge build and it will be included in a new release this weekend 👍
Author
Owner

@ghost commented on GitHub (Jun 24, 2025):

func (m *MessageSummary) UnmarshalJSON(data []byte) error {
	type Alias MessageSummary
	aux := &struct {
		*Alias
	}{
		Alias: (*Alias)(m),
	}
	if err := json.Unmarshal(data, &aux); err != nil {
		return err
	}

	// Normalize nil slices to empty
        if m.From == nil {
		m.From = &mail.Address{}
	}
	if m.To == nil {
		m.To = []*mail.Address{}
	}
	if m.Cc == nil {
		m.Cc = []*mail.Address{}
	}
	if m.Bcc == nil {
		m.Bcc = []*mail.Address{}
	}
	if m.ReplyTo == nil {
		m.ReplyTo = []*mail.Address{}
	}
	if m.Tags == nil {
		m.Tags = []string{}
	}

	return nil
}
<!-- gh-comment-id:2999071084 --> @ghost commented on GitHub (Jun 24, 2025): ``` func (m *MessageSummary) UnmarshalJSON(data []byte) error { type Alias MessageSummary aux := &struct { *Alias }{ Alias: (*Alias)(m), } if err := json.Unmarshal(data, &aux); err != nil { return err } // Normalize nil slices to empty if m.From == nil { m.From = &mail.Address{} } if m.To == nil { m.To = []*mail.Address{} } if m.Cc == nil { m.Cc = []*mail.Address{} } if m.Bcc == nil { m.Bcc = []*mail.Address{} } if m.ReplyTo == nil { m.ReplyTo = []*mail.Address{} } if m.Tags == nil { m.Tags = []string{} } return nil } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#337
No description provided.