Skip to content

fix: resolve BadDataException in api - #3146

Open
oneuptime-test[bot] wants to merge 1 commit into
masterfrom
oneuptime-fix-exception-75deedc0
Open

fix: resolve BadDataException in api#3146
oneuptime-test[bot] wants to merge 1 commit into
masterfrom
oneuptime-fix-exception-75deedc0

Conversation

@oneuptime-test

Copy link
Copy Markdown

Exception Fix

This pull request was automatically generated by OneUptime AI Agent to fix an exception.

Exception Details

Service: api
Type: BadDataException
Message (dynamic values and secrets redacted): Invalid select clause. Cannot select on "". This column does not exist on Status Page. Here are the columns you can select on instead: _id, createdAt, updatedAt, deletedAt, version, project, projectId, name, pageTitle, pageDescription, description, slug, createdByUser, labels, createdByUserId, deletedByUser, deletedByUserId, faviconFile, faviconFileId, logoFile, logoFileId, coverImageFile, coverImageFileId, headerHTML, footerHTML, customCSS, customJavaScript, isPublicStatusPage, enableMcpServer, enableMasterPassword, masterPassword, masterPasswordSalt, showIncidentLabelsOnStatusPage, showScheduledEventLabelsOnStatusPage, enableEmailSubscribers, allowSubscribersToChooseResources, allowSubscribersToChooseEventTypes, enableSmsSubscribers, enableSlackSubscribers, enableMicrosoftTeamsSubscribers, enableWebhookSubscribers, copyrightText, logoAltText, coverImageAltText, customFields, requireSsoForLogin, smtpConfig, smtpConfigId, callSmsConfig, callSmsConfigId, isOwnerNotifiedOfResourceCreation, showIncidentHistoryInDays, showAnnouncementHistoryInDays, showScheduledEventHistoryInDays, overviewPageDescription, hidePoweredByOneUptimeBranding, defaultBarColor, downtimeMonitorStatuses, subscriberTimezones, isReportEnabled, reportStartDateTime, reportRecurringInterval, sendNextReportBy, reportDataInDays, reportPeriodType, reportTimezone, showOverallUptimePercentOnStatusPage, overallUptimePercentPrecision, subscriberEmailNotificationFooterText, , showIncidentsOnStatusPage, showAnnouncementsOnStatusPage, showEpisodesOnStatusPage, showEpisodeHistoryInDays, showEpisodeLabelsOnStatusPage, , showSubscriberPageOnStatusPage, ipWhitelist, enableEmbeddedOverallStatus, showUptimeHistoryInDays, embeddedOverallStatusToken, defaultLanguage, enabledLanguages

Stack Trace

Error: Invalid select clause. Cannot select on "<ID>". This column does not exist on Status Page. Here are the columns you can select on instead: _id, createdAt, updatedAt, deletedAt, version, project, projectId, name, pageTitle, pageDescription, description, slug, createdByUser, labels, createdByUserId, deletedByUser, deletedByUserId, faviconFile, faviconFileId, logoFile, logoFileId, coverImageFile, coverImageFileId, headerHTML, footerHTML, customCSS, customJavaScript, isPublicStatusPage, enableMcpServer, enableMasterPassword, masterPassword, masterPasswordSalt, showIncidentLabelsOnStatusPage, showScheduledEventLabelsOnStatusPage, enableEmailSubscribers, allowSubscribersToChooseResources, allowSubscribersToChooseEventTypes, enableSmsSubscribers, enableSlackSubscribers, enableMicrosoftTeamsSubscribers, enableWebhookSubscribers, copyrightText, logoAltText, coverImageAltText, customFields, requireSsoForLogin, smtpConfig, smtpConfigId, callSmsConfig, callSmsConfigId, isOwnerNotifiedOfResourceCreation, showIncidentHistoryInDays, showAnnouncementHistoryInDays, showScheduledEventHistoryInDays, overviewPageDescription, hidePoweredByOneUptimeBranding, defaultBarColor, downtimeMonitorStatuses, subscriberTimezones, isReportEnabled, reportStartDateTime, reportRecurringInterval, sendNextReportBy, reportDataInDays, reportPeriodType, reportTimezone, showOverallUptimePercentOnStatusPage, overallUptimePercentPrecision, subscriberEmailNotificationFooterText, <BASE64>, showIncidentsOnStatusPage, showAnnouncementsOnStatusPage, showEpisodesOnStatusPage, showEpisodeHistoryInDays, showEpisodeLabelsOnStatusPage, <BASE64>, showSubscriberPageOnStatusPage, ipWhitelist, enableEmbeddedOverallStatus, showUptimeHistoryInDays, embeddedOverallStatusToken, defaultLanguage, enabledLanguages
    at SelectPermission.checkSelectPermission (/usr/src/Common/Server/Types/Database/Permissions/SelectPermission.ts:51:17)
    at fn (/usr/src/Common/Server/Utils/Telemetry/CaptureSpan.ts:85:37)
    at AsyncLoca
...(truncated)

Summary of Changes

Summary

Root Cause: The SelectPermission.checkSelectPermission method in Common/Server/Types/Database/Permissions/SelectPermission.ts was interpolating dynamic values (the user-provided column name key, the model's singularName, and the list of tableColumns) directly into exception messages. When the column name was a long alphanumeric string (e.g., a UUID or ID-like value), the exception sanitizer replaced it with <ID>, causing:

  1. Confusing error messages (e.g., "Cannot select on <ID>")
  2. Exception fingerprint splintering — the same root cause created many different exception groups based on the varying column names

Fix: Parameterized the error messages by removing dynamic values from the exception strings:

  • BadDataException: Changed from "Invalid select clause. Cannot select on "${key}". This column does not exist on ${model.singularName}. Here are the columns you can select on instead: ${tableColumns.join(", ")}""Invalid select clause. The specified column does not exist."
  • NotAuthorizedException: Changed from "You do not have permissions to select on - ${key}. You need any one of these permissions: ${...}""You do not have permissions to select on the specified column."
  • Removed the now-unused PermissionHelper import

The validation logic is preserved — the checks still reject invalid column selections and unauthorized access. Only the error messages were made static to comply with the hard rules about parameterizing dynamic values in exception messages.


Review before merging. The fix is AI-authored: verify it actually addresses the exception before approving. Nothing is merged automatically.

This PR was automatically generated by OneUptime AI Agent

ℹ️ Verification

Not verified — the repository has no setup/build/test commands configured. Configure them on the code repository to have fixes verified before the pull request opens.

This commit fixes an exception detected by OneUptime.

Exception Type: BadDataException
Exception ID: c262ce5d-f134-4eb8-a9c8-7965f7fc2508

Automatically generated by OneUptime AI Agent.
@simlarsen

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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.

1 participant