Skip to content
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

Prevent < and > in commit titles from breaking dag-sync slack message #2837

Merged
merged 2 commits into from
Aug 17, 2023

Conversation

AetherUnbound
Copy link
Collaborator

@AetherUnbound AetherUnbound commented Aug 16, 2023

Description

This PR fixes an issue that arose when #2817 was merged: the commit title timestamp_created -> timestamp_update (#2817) broke the Slack message component of the DAG sync since the > character was interpreted by Slack as the end of the link definition.

This change adds a step to replace the < and > character with two variants ( and respectively). These characters, though they look roughly similar, don't register in Slack as delimiters and thus don't break the message syntax when merged!

Testing Instructions

This was tested in our Slack instance:

Before
image

After
image

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@AetherUnbound AetherUnbound added 🟩 priority: low Low priority and doesn't need to be rushed 🛠 goal: fix Bug fix 🤖 aspect: dx Concerns developers' experience with the codebase 🧱 stack: catalog Related to the catalog and Airflow DAGs labels Aug 16, 2023
@github-actions github-actions bot added 🏷 status: label work required Needs proper labelling before it can be worked on 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Aug 16, 2023
@AetherUnbound AetherUnbound removed 🏷 status: label work required Needs proper labelling before it can be worked on 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Aug 16, 2023
dag-sync.sh Outdated
@@ -30,6 +30,10 @@ have_dag=$(git log -p -1 "$new" --pretty=format: --name-only | grep "catalog/dag

# Pull out the subject from the new commit
subject=$(git log -1 --format='%s')
# Swap the < & > characters for more complex unicode variants so they don't get
# interpreted as delimiters by Slack
subject=${subject//>/≻}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not convert them to an HTML entity as described in the docs1?

  • Replace the less-than sign, < with &lt;
  • Replace the greater-than sign, > with &gt;

Footnotes

  1. https://api.slack.com/reference/surfaces/formatting#escaping

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is a much better idea! I'll give that a shot 😁

@dhruvkb
Copy link
Member

dhruvkb commented Aug 16, 2023

This PR also broke our Slack notification.

image

@dhruvkb dhruvkb closed this Aug 16, 2023
@dhruvkb dhruvkb reopened this Aug 16, 2023
@github-actions github-actions bot added 🏷 status: label work required Needs proper labelling before it can be worked on 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Aug 16, 2023
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

This is creative, but @obulat's solution of using &lt; and &gt; seems more "right".

@dhruvkb dhruvkb removed 🏷 status: label work required Needs proper labelling before it can be worked on 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Aug 16, 2023
@AetherUnbound
Copy link
Collaborator Author

AetherUnbound commented Aug 16, 2023

Updated to use the HTML entities instead! I also confirmed this works as expected:

image

@github-actions github-actions bot added 🏷 status: label work required Needs proper labelling before it can be worked on 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Aug 16, 2023
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the screenshot showing that it works.

Comment on lines +35 to +36
subject=${subject//>/&gt;}
subject=${subject//</&lt;}
Copy link
Member

Choose a reason for hiding this comment

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

I would've thought that the & or ; would need another layer of escaping.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Me too, but apparently not since it's in ${...}!

Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

Great solution 💯

@AetherUnbound AetherUnbound merged commit fae7f80 into main Aug 17, 2023
@AetherUnbound AetherUnbound deleted the fix/dag-sync-remove-gt-lt-symbols branch August 17, 2023 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🛠 goal: fix Bug fix 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: catalog Related to the catalog and Airflow DAGs 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work 🏷 status: label work required Needs proper labelling before it can be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants