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

Labels working but generating an error message #259

Closed
atejada opened this issue May 3, 2023 · 1 comment · May be fixed by #355
Closed

Labels working but generating an error message #259

atejada opened this issue May 3, 2023 · 1 comment · May be fixed by #355

Comments

@atejada
Copy link
Contributor

atejada commented May 3, 2023

Describe the bug
We can use labels on messages to move them to another folder or even the trash. Right now, the correct label will be applied but the SDK will return an error.

To Reproduce
Some steps involved to reproduce the bug and any code samples you can share.

I have omitted the Try - Except to fully return the error message.

messageId = "<MESSAGE_ID>"
labelsDict = {}
labels = nylas.labels.all()
for label in labels:
	labelsDict[label["name"]] = label["id"] 

message = nylas.messages.get(messageId)
message.update_labels([labelsDict["trash"]])
message.save()
print(f"Your message was successfully deleted")

The error message is

nylas.client.errors.NylasApiError: 400 Bad Request. Reason: Invalid 'label_id': {u'display_name': u'TRASH', u'id': u'c1vwdjcvfh0m4w8es2ovp6qq8', u'name': u'trash'}. Nylas Error Type: invalid_request_error

Expected behavior
There shouldn't be an error message. We can do the same in Ruby without further issues

messageId = "<MESSAGE_ID>"

labelsDict = Hash.new
labels = nylas.labels
labels.each{ |label|
	labelsDict[label.name] = label.id
}

begin
	message = nylas.messages.find(messageId)
	message.update(label_ids: [labelsDict["trash"]])
	message.save
	puts "Your message was succesfully deleted"
rescue => error
	puts error.message
end

SDK Version:
Python 3.10.4
Nylas SDK 5.14.0

Additional context
While the error can be bypassed by using pass, there shouldn't be an error at all.

@wiseaidev
Copy link

I've run into the same issue while working on this particular endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants