From a9d2d89505c823094fee430752f66fecb8bd084e Mon Sep 17 00:00:00 2001 From: Brandon Caton Date: Tue, 18 Nov 2025 16:07:09 -0500 Subject: [PATCH] ui: rendering error for splunk logs (PROJQUAY-6934) (#4558) --- web/cypress/e2e/usage-logs.cy.ts | 54 +++++++++++++++++++++ web/src/components/errors/RequestError.tsx | 15 ++++-- web/src/routes/UsageLogs/UsageLogsGraph.tsx | 16 +++++- web/src/routes/UsageLogs/UsageLogsTable.tsx | 16 +++++- 4 files changed, 94 insertions(+), 7 deletions(-) diff --git a/web/cypress/e2e/usage-logs.cy.ts b/web/cypress/e2e/usage-logs.cy.ts index 9d3935334..d1b7ef071 100644 --- a/web/cypress/e2e/usage-logs.cy.ts +++ b/web/cypress/e2e/usage-logs.cy.ts @@ -260,6 +260,33 @@ describe('Usage Logs', () => { cy.contains('No data to display.').should('be.visible'); }); + it('shows Splunk error message when logs are not implemented', () => { + // Mock 501 NOT IMPLEMENTED error from Splunk + cy.intercept('GET', '/api/v1/organization/projectquay/aggregatelogs?*', { + statusCode: 501, + body: { + message: 'Method not implemented, Splunk does not support log lookups', + }, + }).as('aggregateLogsError'); + + cy.intercept('GET', '/api/v1/organization/projectquay/logs?*', { + statusCode: 501, + body: { + message: 'Method not implemented, Splunk does not support log lookups', + }, + }).as('logsError'); + + cy.visit('/organization/projectquay?tab=Logs'); + + // Verify the specific Splunk error message is displayed (not generic error) + cy.contains( + 'Method not implemented, Splunk does not support log lookups', + ).should('be.visible'); + + // Verify generic error is NOT displayed + cy.contains('Unable to complete request').should('not.exist'); + }); + it('filter logs', () => { cy.intercept('GET', '/api/v1/organization/projectquay/logs?*', logsResp); @@ -625,4 +652,31 @@ describe('Usage Logs - Superuser', () => { cy.contains('th', 'Performed by').should('be.visible'); cy.contains('th', 'IP Address').should('be.visible'); }); + + it('shows Splunk error message on superuser page when logs are not implemented', () => { + // Mock 501 NOT IMPLEMENTED error from Splunk + cy.intercept('GET', '/api/v1/superuser/aggregatelogs?*', { + statusCode: 501, + body: { + message: 'Method not implemented, Splunk does not support log lookups', + }, + }).as('aggregateLogsError'); + + cy.intercept('GET', '/api/v1/superuser/logs?*', { + statusCode: 501, + body: { + message: 'Method not implemented, Splunk does not support log lookups', + }, + }).as('logsError'); + + cy.visit('/usage-logs'); + + // Verify the specific Splunk error message is displayed (not generic error) + cy.contains( + 'Method not implemented, Splunk does not support log lookups', + ).should('be.visible'); + + // Verify generic error is NOT displayed + cy.contains('Unable to complete request').should('not.exist'); + }); }); diff --git a/web/src/components/errors/RequestError.tsx b/web/src/components/errors/RequestError.tsx index 9eefd71c5..067aac2f6 100644 --- a/web/src/components/errors/RequestError.tsx +++ b/web/src/components/errors/RequestError.tsx @@ -18,15 +18,19 @@ export default function RequestError(props: RequestErrorProps) { const errorMessage = props.message || getErrorMessageFromUnknown(props.err); const message = capitalizeFirstLetter(errorMessage); + const title = + props.title !== undefined ? props.title : 'Unable to complete request'; return ( - } - headingLevel="h1" - /> + {title && ( + } + headingLevel="h1" + /> + )} {message}