The "`text` missing" warning is technically not always accurate
See original GitHub issueThe _warn_text_if_missing() code is technically not always a valid warning.
Category (place an x
in each of the [ ]
)
- slack_sdk.web.WebClient (sync/async) (Web API client)
- slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
- slack_sdk.models (UI component builders)
- slack_sdk.oauth (OAuth Flow Utilities)
- slack_sdk.socket_mode (Socket Mode client)
- slack_sdk.audit_logs (Audit Logs API client)
- slack_sdk.scim (SCIM API client)
- slack_sdk.rtm (RTM client)
- slack_sdk.signature (Request Signature Verifier)
Although this warning is easy to suppress by setting SKIP_SLACK_SDK_WARNING
in the env, the code is technically incorrect. 😄 Attachments are still supported (and used, since they have some advantages over Blocks). The issue is that attachments have a separate fallback
property, and thus setting a top-level text
property is technically not required, and the deprecation warning shouldn’t be logged.
From the docs:
This can be fixed pretty easily with code like this:
def _warn_if_text_is_missing(endpoint: str, kwargs: Dict[str, Any]) -> None:
attachments = kwargs.get("attachments")
if attachments:
if all([attachment.get("fallback") for attachment in attachments]):
return
missing = "fallback"
else:
text = kwargs.get("text")
if text and len(text.strip()) != 0:
return
missing = "text"
message = (
f"The `{missing}` argument is missing in the request payload for a {endpoint} call - "
f"It's a best practice to always provide a `{missing}` argument when posting a message. "
f"The `{missing}` argument is used in places where content cannot be rendered such as: "
"system push notifications, assistive technology such as screen readers, etc."
)
# for unit tests etc.
skip_deprecation = os.environ.get("SKIP_SLACK_SDK_WARNING")
if skip_deprecation:
return
warnings.warn(message, UserWarning)
I realize this is minor since it’s just a cosmetic warning, but figured I’d mention it anyway.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Guidelines for Issuing AMBER Alerts - Office of Justice Programs
For an AMBER Alert to be effective in recovering a missing child, the law enforcement agency must have enough information to believe that...
Read more >Enable or disable ActiveX settings in Office files
Click the File tab. In the Security Warning area, click Enable Content. Under Enable All Content, click Always enable this document's active content....
Read more >Wireless Emergency Alerts | FEMA.gov
America's Missing: Broadcast Emergency Response (AMBER) Alerts are urgent bulletins issued in child-abduction cases.
Read more >REDCap downtime: Tuesday, Dec. 8
All the missing data codes are displayed for reference at the top of the Codebook page. ... If an alert has the “Ensure...
Read more >Dealing with missing data: Key assumptions and methods for ...
Its purpose is not to re-create the individual missing values as close as possible to the true ones, but to handle missing data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@agrawaltarun When using blocks, you should provide a top-level summary
text
item. (This is used for notifications, for example.) The warning you’re seeing is alerting you that it is missing.e.g.:
Thanks @seratch & @eddyg , this is helpful. The warning no longer appears post updating the request payload .