Skip to content

bug: accept urls in --notify-webhooks - #672

Open
Amadeus-22 wants to merge 2 commits into
QuantConnect:masterfrom
Amadeus-22:bug-671-notify-webhooks-url
Open

Amadeus-22 wants to merge 2 commits into
QuantConnect:masterfrom
Amadeus-22:bug-671-notify-webhooks-url

Conversation

@Amadeus-22

Copy link
Copy Markdown

Closes #671.

  • lean cloud live deploy --notify-webhooks split the value on every colon. With a real URL the scheme (and port) was cut off the address and the remainder was parsed as a header, raising IndexError: list index out of range. A header value containing = was truncated.
  • The parsing moves to _parse_webhook_config: only the trailing NAME=VALUE parts are headers, the rest is the address, and each header is split on its first =. Values that worked before parse the same way.
  • test_cloud_live_deploy_with_notifications gets three URL cases (no headers, port plus query string, header value with =). They fail on master and pass with the fix; the expected values are now written out instead of being re-parsed with the same logic as the command.
  • pytest tests/commands/cloud/live/test_cloud_live_commands.py passes (68 tests, Python 3.12) and python static_analysis.py is clean.

🤖 Generated with Claude Code

Amadeus-22 and others added 2 commits October 6, 2026 14:49
The webhook configuration was split on every colon, so the scheme and port
of a URL were cut off the address and the rest was read as a header, which
raised IndexError for any real URL. Only the trailing NAME=VALUE parts are
headers now, and a header is split on its first '=' so values containing
'=' are kept whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Split every --notify-* value on commas outside double quotes, and each
  entry on colons with a csv reader, so a quoted url, header, subject or
  token can contain ',' and ':'.
- Email subjects can contain ':' without quotes, and an email without a
  subject now aborts with a clear error instead of a ValueError.
@jhonabreul

Copy link
Copy Markdown
Collaborator

Thanks for the fix. I pushed a follow-up commit (188b68f) on top of it.

Strings that still failed with the previous commit

Splitting on : and keeping the trailing NAME=VALUE parts as headers works for most URLs, but some inputs can't be told apart without quoting, and the outer split(",") still broke values with commas:

--notify-webhooks value Parsed as
https://x.com/hook?a=1:b=2 address https://x.com/hook?a=1, header b: 2
https://user:pw=1@x.com/hook address https://user, header pw: 1@x.com/hook
https://x.com/hook:Authorization=Bearer a:b no headers, the whole string as the address
https://x.com/h?ids=1,2:A=b two webhooks: https://x.com/h?ids=1 and 2 with header A: b

The other notify options had the same comma issue, and --notify-emails raised a ValueError for a subject containing : (a@x.com:Alert: order filled) or for an entry without a subject.

What changed

  • Every --notify-* value is split on commas outside double quotes, and each entry on : with a csv reader, so a part wrapped in double quotes is never split. The webhook rule from your commit (trailing NAME=VALUE parts are headers) runs on those parts, so unquoted values parse the same as before.
  • Quoting fixes the cases above:
    • "https://x.com/hook?a=1:b=2":Auth=k
    • "https://user:pw=1@x.com/hook"
    • https://x.com/hook:"Authorization=Bearer a:b"
    • "https://x.com/h?ids=1,2":A=b
    • a@x.com:"Fills, orders"
    • 123:"to,ken"
  • Email subjects can contain : without quotes, and an email entry without a subject aborts with Invalid --notify-emails configuration '<value>', expected 'email:subject'.
  • The help text of --notify-emails, --notify-webhooks and --notify-telegram explains when to quote; README regenerated with scripts/readme.py.
  • test_cloud_live_deploy_with_quoted_notifications covers the quoted cases for all four options, and test_cloud_live_deploy_aborts_when_email_notification_has_no_subject covers the error. All of them fail on the previous commit; tests/commands/cloud/live/test_cloud_live_commands.py passes (77 tests) and static_analysis.py is clean.

An unquoted comma inside a URL (?ids=1,2) still splits the webhook. That input is ambiguous with url1:h=v,url2, so the help text asks for quotes instead.

@Amadeus-22

Copy link
Copy Markdown
Author

Thanks for taking it further, @jhonabreul. I read 188b68f: splitting outside double quotes resolves the cases I couldn't disambiguate, and keeping the trailing NAME=VALUE rule means unquoted values behave as before. The email subject fix and the explicit error for a missing subject are good additions. Nothing to add from my side.

@jhonabreul jhonabreul left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lean cloud live deploy --notify-webhooks fails when the address is a URL

2 participants