Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

gh deploy resulting in TypeError: expected string or bytes-like object #164

Closed
opichals opened this issue Apr 9, 2018 · 8 comments
Closed

Comments

@opichals
Copy link
Contributor

opichals commented Apr 9, 2018

Using bb version = 0.15.10 and issuing

bb gh deploy https://github.com/apiaryio/.../pull/12234

I got the following error at the end

Waiting for tests to pass...
.........................
Ready for deploy! Do you want me to deploy b70d1b4223c2eaa5b60428aa92006786fedbe953 as the new version of Apiary? [y/N]: y
SSL_PORT is set to other value than 9000; GitHub login will not work
SSL_PORT is set to other value than 9000; GitHub login will not work
SSL_PORT is set to other value than 9000; GitHub login will not work
Traceback (most recent call last):
  File "/usr/local/bin/bb", line 5, in <module>
    main()
  File "/usr/local/lib/python3.6/site-packages/blackbelt/tasks.py", line 32, in main
    cli()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/commands/gh.py", line 51, in deploy
    deploy_command(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/commands/gh.py", line 60, in deploy_command
    do_deploy(pr_url)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/handle_github.py", line 394, in deploy
    ticket_id = get_pr_ticket_id(merge_info['description'])
  File "/usr/local/lib/python3.6/site-packages/blackbelt/handle_github.py", line 333, in get_pr_ticket_id
    match = re.search(PR_PHRASE_PREFIX + ' ' + r"\[.*\]\(https://trello.com/c/(?P<id>\w+)/.*\)", description)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
@opichals
Copy link
Contributor Author

$ `type -p bb | xargs head -n 1 | cut -c 3-` --version
Python 3.6.4

@kylef
Copy link
Member

kylef commented Apr 10, 2018

Was the pull request that caused this https://github.com/apiaryio/apiary/pull/5380 ? you seem to have changed the argument to invalid one in the report steps.

If so, I wonder if it is because it has empty description, perhaps API returns null and therefore the description past to re.search(PR_PHRASE_PREFIX + ' ' + r"\[.*\]\(https://trello.com/c/(?P<id>\w+)/.*\)", description) is actually None thus causing the TypeError

@opichals
Copy link
Contributor Author

Nope, it was this one https://github.com/apiaryio/apiary/pull/5377

@kylef
Copy link
Member

kylef commented Apr 12, 2018

I tested my guess about empty descriptions out and GitHub API does return an empty string instead of None. Not sure how to reproduce this one. I tested by applying patch to my black-belt dev version:

diff --git a/blackbelt/handle_github.py b/blackbelt/handle_github.py
index ab6c723..3a92b38 100644
--- a/blackbelt/handle_github.py
+++ b/blackbelt/handle_github.py
@@ -178,6 +178,8 @@ def merge(pr_url):
     """

     pr_details = get_pr_details(pr_url)
+    print(get_pr_ticket_id(pr_details['body']))
+    raise Exception('prevent next steps and deploy')

     # Check if PR is ready to merge - OPEN status
     verify_pr_state(pr_details)

This patch for you should raise the same exception as before, perhaps using it we can debug this further on your end.

@opichals
Copy link
Contributor Author

opichals commented Apr 12, 2018

Got the same thing yesterday with https://github.com/apiaryio/apiary/pull/5382 deploy.

Yes, with the patch it reports the same exception. So it seems it is the 'description' being empty.

$ bb gh deploy https://github.com/apiaryio/apiary/pull/5382
Traceback (most recent call last):
  File "/usr/local/bin/bb", line 5, in <module>
    main()
  File "/usr/local/lib/python3.6/site-packages/blackbelt/tasks.py", line 32, in main
    cli()
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/commands/gh.py", line 51, in deploy
    deploy_command(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/commands/gh.py", line 60, in deploy_command
    do_deploy(pr_url)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/handle_github.py", line 359, in deploy
    merge_info = merge(pr_url)
  File "/usr/local/lib/python3.6/site-packages/blackbelt/handle_github.py", line 181, in merge
    print(get_pr_ticket_id(pr_details['body']))
  File "/usr/local/lib/python3.6/site-packages/blackbelt/handle_github.py", line 336, in get_pr_ticket_id
    match = re.search(PR_PHRASE_PREFIX + ' ' + r"\[.*\]\(https://trello.com/c/(?P<id>\w+)/.*\)", description)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

@kylef
Copy link
Member

kylef commented Apr 12, 2018

@opichals Want to add pr_details(['body']) after pr_details = get_pr_details(pr_url) so we can see what type body is?

@opichals
Copy link
Contributor Author

@kylef Sure, the result of print(pr_details['body']) is None

@abtris
Copy link
Contributor

abtris commented Sep 12, 2018

Migrated to apiaryio/bb#23

@abtris abtris closed this as completed Sep 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants