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

TypeError with board["id"] prevents importing #26

Open
pvavra opened this issue Apr 29, 2021 · 14 comments
Open

TypeError with board["id"] prevents importing #26

pvavra opened this issue Apr 29, 2021 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@pvavra
Copy link

pvavra commented Apr 29, 2021

Import fails with the following traceback message:

Traceback (most recent call last):
  File "/home/peter/tmp/env_trello_migration/bin/trello-to-deck", line 52, in <module>
    createdBoard = api.createBoard(truncate(board.title, MAX_TITLE_LENGTH), board.color)
  File "/home/peter/tmp/env_trello_migration/lib/python3.8/site-packages/trello_to_deck/deck.py", line 110, in createBoard
    boardId = board["id"]
TypeError: list indices must be integers or slices, not str

To Reproduce
Steps to reproduce the behavior:

  1. create new venv:
python3 -m venv ~/tmp/env_trello_migration; source ~/tmp/env_trello_migration/bin/activate; pip install -U pip setuptools
  1. clone & install repo:
cd ~/tmp; git clone https://github.com/maxammann/trello-to-deck.git
cd ~/tmp/trello-to-deck 
pip install .

up till now, no obvious issues (a deprecation warning during the install mentions a change in pip 21.3 functionality, but it works as intended, as far as I can tell)..

and then the import:

trello-to-deck ~/Downloads/fmri_procedural.json [...]

before the trace-back, I get some "stats" on the json:

Found:
6 labels
4 stacks
35 cards (archived and non-archived)

Operating system:
Ubuntu 20.04.2 LTS
with python 3.8.5

Nextcloud version:
It's my uni's cloud instance, so cannot say much about it. But also doesn't seem relevant.

If useful for debugging, could post the json.

@pvavra pvavra added the bug Something isn't working label Apr 29, 2021
@maxammann
Copy link
Owner

This is very strange as it seems like the API responded with an array instead of an object. I suppose that there is an issue with the Nextcloud instance. The version of deck should not be the problem as I added a compatibility check some time ago.

The JSON in your Downloads folder is not the problem.

Can you edit the file /home/peter/tmp/env_trello_migration/lib/python3.8/site-packages/trello_to_deck/deck.py and put a print(board) before line 110?

@pvavra
Copy link
Author

pvavra commented May 3, 2021

This seems to return the list of boards I already have on that cloud instance:

[{'title': 'Feedback Leo', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': '87665b', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1620028193, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 152, 'ETag': '8544528bdc49c1636e82728c7d932111'}, {'title': 'feedback prisma', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': '6ea68f', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1619710127, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 185, 'ETag': '40b54e2bc1aa484a5cd9966c13dda10a'}, {'title': 'gardening', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'ffffff', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1618848957, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 188, 'ETag': '965f80fc2252459808d8bc3495643f43'}, {'title': 'home improvement', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'ffffff', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1620028172, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 191, 'ETag': '27a4485b5de0f9e66b70db0cc8a57d69'}, {'title': 'desc vs exp', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'ffffff', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1618849002, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 194, 'ETag': '7c6583cf51e78047e1efa092ce239460'}, {'title': 'fmri ug', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'ffffff', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1618849090, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 197, 'ETag': 'f09d904d0e355314c8b79e84badbd026'}, {'title': 'General', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'f0c960', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1620028199, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 305, 'ETag': 'd2efb54b52476a873219c46e861e521e'}, {'title': 'Teaching', 'owner': {'primaryKey': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'uid': '4dcc0f53-e83f-4e8c-ae93-4bb21a69c537', 'displayname': 'Peter Vavra', 'type': 0}, 'color': 'ce6bfc', 'archived': False, 'labels': [], 'acl': [], 'permissions': {'PERMISSION_READ': True, 'PERMISSION_EDIT': True, 'PERMISSION_MANAGE': True, 'PERMISSION_SHARE': True}, 'users': [], 'shared': 0, 'stacks': [], 'deletedAt': 0, 'lastModified': 1620033912, 'settings': {'notify-due': 'assigned', 'calendar': True}, 'id': 308, 'ETag': '1b133322006c6296b8193374cd40c729'}]

@maxammann
Copy link
Owner

maxammann commented May 3, 2021

Ok that indicates that trello-to-deck somehow sends a GET instead of a POST. I'll see whether I can find a reason

'Feedback Leo' already existed on the server, right?

@maxammann
Copy link
Owner

maxammann commented May 3, 2021

Can you execute this curl command? It creates a board called xyz. That works for me.

curl -X POST $base_url/index.php/apps/deck/api/v1.0/boards --header "Content-Type: application/json" --data '{"title":"xyz","color":""}' --header "OCS-APIRequest: true" -u $user:$token_password

I suppose that your nextcloud server is returning a redirect http code here.

@pvavra
Copy link
Author

pvavra commented May 3, 2021

returns the following:

{"title":"xyz","owner":{"primaryKey":"4dcc0f53-e83f-4e8c-ae93-4bb21a69c537","uid":"4dcc0f53-e83f-4e8c-ae93-4bb21a69c537","displayname":"Peter Vavra","type":0},"color":"","archived":false,"labels":[{"title":"Finished","color":"31CC7C","boardId":329,"cardId":null,"lastModified":1620057704,"id":1328,"ETag":"02fe60eb89eb0783a257e4ac29a189cc"},{"title":"To review","color":"317CCC","boardId":329,"cardId":null,"lastModified":1620057704,"id":1331,"ETag":"02fe60eb89eb0783a257e4ac29a189cc"},{"title":"Action needed","color":"FF7A66","boardId":329,"cardId":null,"lastModified":1620057704,"id":1334,"ETag":"02fe60eb89eb0783a257e4ac29a189cc"},{"title":"Later","color":"F1DB50","boardId":329,"cardId":null,"lastModified":1620057704,"id":1337,"ETag":"02fe60eb89eb0783a257e4ac29a189cc"}],"acl":[],"permissions":{"PERMISSION_READ":true,"PERMISSION_EDIT":true,"PERMISSION_MANAGE":true,"PERMISSION_SHARE":true},"users":[],"stacks":[],"deletedAt":0,"lastModified":0,"settings":[],"id":329,"ETag":"cfcd208495d565ef66e7dff9f98764da"}

@pvavra
Copy link
Author

pvavra commented May 3, 2021

and it did create the board xyz (with no lists or cards)

@maxammann
Copy link
Owner

And you executed the curl command as-is, right without -L, --location flats, right?
If yes then I really do not have an idea right now what is going on. The python code clearly calls requests.post(..) which does a post request. A post request can never return a list of already existing boards.

@pvavra
Copy link
Author

pvavra commented May 3, 2021

yes, just prepended it with the variable assignments, i.e. base_url=[...]; user=[...]; token_password=[..]; [copy-paste-here], all in one call.

I've also asked our IT to give me some details on versions of both nextcloud and decks installation, but have to wait till I hear back.

@maxammann
Copy link
Owner

Which python-requests version are you using? python3 -c "import requests; print(requests.__version__)"

@pvavra
Copy link
Author

pvavra commented May 3, 2021

2.25.1

just a quick follow-up on the -L flag on curl: I'm using zsh with oh-my-zsh. I doubt it, but maybe that sets some defaults on curl.. I'll try to see whether I find something on it..

@maxammann
Copy link
Owner

Oke, next steps would be to create a minimal example in python. I'll do this in the next days.

@maxammann
Copy link
Owner

Probably the issue is not the python code but the server: https://stackoverflow.com/questions/26149181/python-requests-post-doing-a-get

Can you send me the url of the server via mail? [email protected]

Did you maybe use http:// instead of https://?

@pvavra
Copy link
Author

pvavra commented May 4, 2021

I was indeed using http:// :(

Replacing the calls with https allowed me to import my jsons.

Thanks for hunting this down and sorry it turned out to be such a simple mistake on my part..

Issue can be closed, unless you want me to still send you stuff/test things.

And thanks for the amazing tool and your support!

@maxammann
Copy link
Owner

Good to hear! I almost went crazy while looking at the 2 lines of code which do weird stuff! :)

I will leave this open, as it still is bad behavior. I probably will prohibit redirects and simply abort the import with a proper error message. Therefore, I'll leave this open :)

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

No branches or pull requests

2 participants