Skip to content

Add invalid announcements error widget and add related test (#2568)#5250

Open
bstepanovski wants to merge 3 commits intomasterfrom
invalid-announcements-error-widget-2658
Open

Add invalid announcements error widget and add related test (#2568)#5250
bstepanovski wants to merge 3 commits intomasterfrom
invalid-announcements-error-widget-2658

Conversation

@bstepanovski
Copy link
Copy Markdown
Contributor

@bstepanovski bstepanovski commented Apr 1, 2026

Fixes #2658

  • Show invalid announcements as error alerts instead of failing silently.
  • Adds error handling in Announcement#opts, updates the view to render a danger alert
  • Includes an integration test for malformed YAML.

Also manually tested in the dashboard with both valid and invalid announcements.

Copy link
Copy Markdown
Contributor

@Bubballoo3 Bubballoo3 left a comment

Choose a reason for hiding this comment

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

The model updates here look good, but we are handling a bit too much logic in the view side. By checking validity in the controller and raising any errors from there, we will save a lot of code and headache in the views.

It looks like some of the other announcement tests are failing, so you will probably want to add an announcement to your dev dashboard to test it out manually and see what's going on. If you follow the trace of where the announcement path comes from, you'll see in UserConfiguration#announcement_path that it will read from an OOD_ANNOUNCEMENT_PATH environment variable before looking in the default locations. So you should be able to set this in a .env.local and point it to a file in your home directory.

@@ -0,0 +1,24 @@
require 'test_helper'

class AnnouncementParseErrorTest < ActionDispatch::IntegrationTest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can just add this to announcement_views_test to keep things in one place

<% end %>
</div>
<% end %> No newline at end of file
<% if announcement.parse_error? %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We typically want to do error checking in the controller (ApplicationController#set_announcements in this case)

@@ -0,0 +1,8 @@
<div class="alert alert-danger card">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't have to make a new alert partial for this error, we can use a shared alert structure by calling flash.now from the controller.

@github-project-automation github-project-automation Bot moved this from Awaiting Review to Changes Requested in PR Review Pipeline Apr 1, 2026
@johrstrom johrstrom closed this Apr 1, 2026
@johrstrom johrstrom reopened this Apr 1, 2026
@github-project-automation github-project-automation Bot moved this from Changes Requested to Merged/Closed in PR Review Pipeline Apr 1, 2026
@github-project-automation github-project-automation Bot moved this from Merged/Closed to Awaiting Review in PR Review Pipeline Apr 1, 2026
@bstepanovski bstepanovski requested a review from Bubballoo3 April 14, 2026 11:26
@Bubballoo3
Copy link
Copy Markdown
Contributor

Bubballoo3 commented Apr 14, 2026

This certainly looks better and it now does everything in the right place. Unfortunately something in FilesController seems to be snagging on the error and duplicating it every time a files/fs page attempts to load (the stacking is produced by clicking a favorites link from inside a files table view). In addition to duplicating the error message, it also stops the actual files request from responding properly. I will try to dig in and help narrow down what the actual issue is, but would love to know if you are able to replicate

image

Just to be clear, this should be a 'soft' error that alerts on every page but does not block any other code like it does here.

@Bubballoo3 Bubballoo3 moved this from Awaiting Review to Changes Requested in PR Review Pipeline Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

invalid announcements should show error widgets

4 participants