Skip to content

Fixes #39253 - Implement "Not Found" error handling for invalid Job I…#1030

Open
pondrejk wants to merge 3 commits into
theforeman:masterfrom
pondrejk:invocations-empty-page
Open

Fixes #39253 - Implement "Not Found" error handling for invalid Job I…#1030
pondrejk wants to merge 3 commits into
theforeman:masterfrom
pondrejk:invocations-empty-page

Conversation

@pondrejk
Copy link
Copy Markdown
Contributor

…nvocation IDs

SAT-44544

image

Copy link
Copy Markdown
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

Some nitpicks, seems to work well.

<EmptyStateBody>
{sprintf(
__(
'There is no job invocation with id %s or there are access permissions needed. Please contact your administrator if this issue continues.'
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.

From the top of my head, I could envision four error cases that can happen:

  1. The user doesn't have permission to view job invocations at all (backend should give 403 unauthorized)
  2. The user doesn't have permission to view this particular job invocation (backend should give 404)
  3. The user has permission to view, but the job invocation doesn't exist (backend should give 404)
  4. The backend failing to process the request (think 500 ISE)

Should we distinguish 1 vs 2+3 vs 4?

With that being said, the old page showed "Not found" for all cases, except 4 so feel free treat this as optional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to include the backend message to the page? It could be more informative without us needing to introduce some parsing logic, wdyt?

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.

Not sure if the backend says anything reasonable, but worth a try.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In some cases the backend adds a nice message like for case 3 »Resource job_invocation not found by id '88'«

<EmptyStateBody>
{sprintf(
__(
'There is no job invocation with id %s or there are access permissions needed. Please contact your administrator if this issue continues.'
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.

Since we know what the permissions required are, should we list them as we do on the unauthorized page?


const jobInvocationsIndexPath = '/job_invocations';

const JobInvocationEmptyState = ({ jobInvocationId }) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAIR we have some patterns in core:

Should we re-use them instead of implementing a brand new specific page for it? I mean if they are not feasible, that's okay, I'm just asking if it was considered? I might lag behind our UI changes, so not sure if those aren't marked for future removal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did consider them, but found them a bit too restrictive. Otoh, if its worth it I can also extend them based on what we agree upon here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about them was too restrictive? might be worth to extend them as you said

@MariaAga MariaAga self-assigned this Apr 28, 2026
@pondrejk pondrejk force-pushed the invocations-empty-page branch from 412d2fe to 236a8c6 Compare May 12, 2026 12:56
@pondrejk pondrejk force-pushed the invocations-empty-page branch from 236a8c6 to afbb4da Compare May 12, 2026 13:33
@pondrejk
Copy link
Copy Markdown
Contributor Author

@ofedoren @MariaAga @adamruzicka since the last time:

  • I changed thing so that the EmptyStatePattern from core is used
  • I added a note about needed perms
  • I display also the message from server
Screenshot 2026-05-12 at 15 41 38

Copy link
Copy Markdown
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

It's more a high level review, I'd rather leave the React stuff for someone else :)

  1. One of the reasons why I wanted to re-use or enhance and re-use something from Foreman is because we're still trying to unify the UI across the pages at some degree.

Looking at the recent change to models page in Foreman and here I see a bunch of common things, essentially a lot of repetitions, which makes it harder to unify in the future if we'd need some changes. Anyway, at least now these two pages have at least different strings:

Image Image

It just feels odd :/

  1. We'd rather add tests, especially since we can use AI for that, just make sure it actually tests something.

  2. There is yet another custom error formatter. And AFAIU there is an idea of creating a general formatter that can be re-used then in other places. Should we wait for that or at least mark somehow to revisit this one and replace after the general/common one is available.

  3. Some inline comments.


const jobInvocationsIndexPath = '/job_invocations';

const JobInvocationEmptyState = ({ jobInvocationId, errorMessage = null }) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We already use defaultProps for that

Suggested change
const JobInvocationEmptyState = ({ jobInvocationId, errorMessage = null }) => {
const JobInvocationEmptyState = ({ jobInvocationId, errorMessage }) => {

@pondrejk
Copy link
Copy Markdown
Contributor Author

Looking at the recent change to models page in Foreman and here I see a bunch of common things, essentially a lot of repetitions, which makes it harder to unify in the future if we'd need some changes.

Well I thought the point of these patterns was to declare the overall shape of things for the implementations to fill in their own content that could be site specific. To me they look fairly unified, I can extend the foreman pattern, but then we'd need to agree on which parts should be unified and which should stay modifiable

@pondrejk
Copy link
Copy Markdown
Contributor Author

this is now dependent on theforeman/foreman#10986

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.

4 participants