slackapi / slackapi/python-slack-sdk

Inconsistent SlackObjectFormationError raising when empty text is provided.

Ouverte
#1,267 5 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@hello-ashleyintech y travaille déjà.

Depuis le 20/9/2022.

enhancement
Langage dominant
Python
Étoiles
4k
Forks
857
Merge moyen
22 h 21 min
PR mergées (30 j)
16

Description

Given the following:

>>> SectionBlock(text="").to_dict()
SlackObjectFormationError: text or fields attribute must be specified

This is all correct enough and good enough. What's happening behind the scenes appears to be that TextObject.parse is used and does a truthy test on the incoming text, and returns None as opposed to an empty string.

Where that begins to go wrong, is here:

>>> SectionBlock(text=MarkdownTextObject(text="")).to_dict()
{'text': {'type': 'mrkdwn'}, 'type': 'section'}

Slack will reject that as erroneous. If it's sent back as part of the acknowledgement response as a response_action we won't necessarily see (receive) an error related to failing to parse the JSON schema. Slack's block kit builder says of it: Missing required field: text

Category
  • slack_sdk.models (UI component builders)
Desired outcome

Ideally, I'd like to be able to trust (more) that the validation present in slack_sdk is going to raise on invalid configurations early, and consistently -- that is, where possible I'd like to assume that putting together something "empty" even if I've opted to use the classes instead of an equivalent base type (str, dict) should raise.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.