-
Notifications
You must be signed in to change notification settings - Fork 657
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
fix(1528): better warnings about webclient fallbacks #1529
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to send this PR! Can you check my comments?
@@ -278,7 +278,7 @@ describe('WebClient', function () { | |||
.map((v) => ({ method, args: Object.assign({}, v, args) })) | |||
return acc.concat(textPatterns) | |||
}, []).forEach(({ method, args }) => { | |||
it(`should send both text and fallback-argument-specific warning to logs when client executes ${method} without text argument(${args.text === "" ? "empty" : args.text}) nor without attachment-level fallback argument (${args.attachments[0].fallback === " " ? "empty" : args.attachments[0].fallback})`, function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the existing tests should behave the same. My intention here is that we should change the behavior only for the pattern with no text + valid fallbacks for all attachments, which is your situation. Can you add a new test pattern to cover your situation?
packages/web-api/src/WebClient.ts
Outdated
@@ -714,9 +714,10 @@ function warnIfFallbackIsMissing(method: string, logger: Logger, options?: WebAP | |||
'Alternatively, you can provide an attachment-level `fallback` argument, though this is now considered a legacy field (see https://api.slack.com/reference/messaging/attachments#legacy_fields for more details).'; | |||
if (isTargetMethod && typeof options === 'object') { | |||
if (isEmptyText(options)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention of the new requirement is something like this:
if (missingAttachmentFallbackDetected(options)) {
if (isEmptyText(options)) {
logger.warn(buildMissingTextWarning());
}
logger.warn(buildMissingFallbackWarning());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i couldn't use that snippet ^ exactly because i think it broke existing functionality but i just pushed a commit that i think matches your original intention. could you give this another look when you get a chance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my belated response here. Looks great to me 👍
Summary
fixes #1528
this PR updates the warning logic for the conversation api to better match this logic:
Requirements