Skip to content

Chore(cicd_bot): Show logged warnings/errors in the check output#4938

Merged
erindru merged 1 commit intomainfrom
erin/cicd-bot-warning-error
Jul 10, 2025
Merged

Chore(cicd_bot): Show logged warnings/errors in the check output#4938
erindru merged 1 commit intomainfrom
erin/cicd-bot-warning-error

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Jul 9, 2025

Prior to this PR, warnings were logged to the console only. This made them vastly less noticeable/actionable because you'd only ever see them if you were trying to troubleshoot an issue.

PR #4900 introduces a warning that we want people to take notice of / action.
So, this PR:

  • Refactors how the PR Environment Summary Markdown is generated as it was getting quite large and unwieldy
  • Update MarkdownConsole errors / warnings captured output to produce alert blocks instead of code blocks
  • Utilize these when writing the check output

Before (warnings/errors not shown in check output):
Screenshot From 2025-07-09 17-48-05

After (warnings collapsed if too long):
Screenshot From 2025-07-10 14-51-02

After (warnings expanded)
Screenshot From 2025-07-10 14-51-11

After (warnings truncated if too long)
Screenshot From 2025-07-10 15-02-14

After (error example)
Screenshot From 2025-07-10 14-50-40

Copy link
Contributor

@themisvaltinos themisvaltinos left a comment

Choose a reason for hiding this comment

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

lgtm the alert block is really nice there! one question I have is about the error alert and how it looks because I can't find examples of it on GitHub

return f"No changes to apply.{plan_flags_section}"

return f"{difference_summary}\n{missing_dates}{plan_flags_section}"
warnings_block = self._console.captured_warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

fmi what is the reason that here you don't consume so the error and warnings remain but in get_pr_environment_summary you use consume_captured_warnings instead

Copy link
Collaborator Author

@erindru erindru Jul 9, 2025

Choose a reason for hiding this comment

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

Good question.

I need to revisit this, upon further reflection it's essentially a no-op and because the warnings already get consumed in get_pr_environment_summary which means self._console.captured_warnings always returns ''

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated these to the consume() equivalents. Most of the time, warnings in particular will be already consumed by the PR Environment Synced step, this would just capture any extra ones raised between the steps

Copy link
Contributor

Choose a reason for hiding this comment

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

yes i see, it is indeed a bit hard to follow the steps and see what has been consumed

if errors:
self._errors.append("\n".join(str(ex) for ex in errors))
super().log_failed_models(errors)
self._errors.extend([str(ex) for ex in errors])
Copy link
Contributor

Choose a reason for hiding this comment

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

should this have similar logic check like in log_error if message not in self._errors: or the errors can't have duplicates here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I was torn between preserving the existing logic or adjusting it.

I should just make this consistent with _warnings

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added in deduplication step. However, I need to do more testing because im not actually sure if this codepath is ever hit.

I've noticed another issue with how failures are reported when a model throws an exception but i'll raise a new PR for that

self._print(f"```\n\\[WARNING] {short_message}```\n\n")
@property
def captured_errors(self) -> str:
return self._render_alert_block("ERROR", self._errors)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦‍♂️ I should actually read the documentation I linked.

Yes, this should be CAUTION and not ERROR because there is no ERROR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated this

Copy link
Contributor

Choose a reason for hiding this comment

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

great and thanks for providing a example of how it looks

@eakmanrq
Copy link
Contributor

eakmanrq commented Jul 9, 2025

The warning looks great! Some things to think about (sorry if this is addressed in PR I just quickly reviewed it)

  • There are some warning that will keep showing up and users will want to ignore. The example from the screenshot is good since they might have accepted they are using a non-prod state db. Do you think they would be annoyed seeing this at the top every time? Should it potentially be collapsable and start collapsed so they can opt-in to seeing the information? The plan information on the PR comment does something like this currently
  • Checks have a max length and I wonder what users would prefer between truncating the normal check information and truncating warning/errors. Have you thought about that?
  • Are you aware of any warning that could get spammy that we send out in SQLMesh? I haven't worked on console since it added this warning logic so I'm not familiar with it but checking if we are concerned about noisy warnings spamming the top of the check

@erindru
Copy link
Collaborator Author

erindru commented Jul 9, 2025

There are some warning that will keep showing up and users will want to ignore. Do you think they would be annoyed seeing this at the top every time?
Are you aware of any warning that could get spammy that we send out in SQLMesh?

Yeah, I did think about this. The thing is, using the warehouse for state is a completely sub-par experience so I don't think its the worst thing in the world if users get annoyed enough to use a proper database. If they're trying out SQLMesh in a POC capacity, it's also a good reminder that they are running in a sub-optimal mode.

The other warnings that might get spammy are:

  • the warning that gets triggered when we automatically adjust DuckDB config to prevent deadlocks if someone is using DuckDB for state. This probably wont be an issue in CICD
  • SQLGlot warnings like <sql> could not be semantically understood as it contains unsupported syntax which might not be actionable. Users should be seeing these locally as well though

Unfortunately, it looks like collapsed sections dont work with alert blocks:
Screenshot From 2025-07-10 10-29-58

The goal is to align with the CLI, so if the warnings are showing in the CLI then I think we should be surfacing them in the check output too.

Checks have a max length and I wonder what users would prefer between truncating the normal check information and truncating warning/errors. Have you thought about that?

I did not. Putting a limit on how much warning info is emitted (with a note to check the console output if it gets exceeded) sounds like a good idea, i'll implement it

@erindru
Copy link
Collaborator Author

erindru commented Jul 9, 2025

Oh, interesting, it looks like collapsible sections can go inside alert blocks:

Warning

The PR plan produced the following warnings: foo

Would that be preferable, coupled with truncating the warning text if it goes over a certain threshold?

@erindru erindru force-pushed the erin/cicd-bot-warning-error branch from bc3f02a to b94bc9c Compare July 10, 2025 01:41
@erindru erindru changed the title Chore(cicd_bot): Show warnings in the check output Chore(cicd_bot): Show logged warnings/errors in the check output Jul 10, 2025
self.alert_block_max_content_length = int(kwargs.pop("alert_block_max_content_length", 500))
self.alert_block_collapsible_threshold = int(
kwargs.pop("alert_block_collapsible_threshold", 200)
)
Copy link
Collaborator Author

@erindru erindru Jul 10, 2025

Choose a reason for hiding this comment

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

I've hardcoded these thresholds for now but it would be a low lift to make them configurable if required.

alert_block_max_content_length - maximum amount of text to put inside a [!WARNING] block
alert_block_collapsible_threshold - if the text is longer than this, it isn't truncated (unless it exceeds alert_block_max_content_length), but it's wrapped inside a collapsible section within the [!WARNING] block

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I feel the collapsible section within the block is much better and since it is collapsible I don't see the need to truncate and have the please check the console message anymore

@erindru erindru force-pushed the erin/cicd-bot-warning-error branch from b94bc9c to 2622d0b Compare July 10, 2025 01:58
@erindru erindru force-pushed the erin/cicd-bot-warning-error branch from 2622d0b to 0cf8f9d Compare July 10, 2025 02:44
@erindru erindru merged commit 8be77dc into main Jul 10, 2025
27 checks passed
@erindru erindru deleted the erin/cicd-bot-warning-error branch July 10, 2025 20:48
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.

3 participants