Skip to content

Commit af7bf14

Browse files
authored
fix(csvMethod): update rate limit error msg for iox (#6510)
* fix(csvMethod): update rate limit error msg for iox * fix: update wording of error message * chore: add an enum for query response * chore: use shared runQuery response enum
1 parent 0224301 commit af7bf14

File tree

10 files changed

+43
-19
lines changed

10 files changed

+43
-19
lines changed

src/alerting/utils/activity.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {MONITORING_BUCKET} from 'src/alerting/constants'
1010
import {CancelBox, CheckIDsMap, StatusRow} from 'src/types'
1111
import {RunQueryResult} from 'src/shared/apis/query'
1212
import {LoadRowsOptions, Row} from 'src/types'
13+
import {RunQueryResponse} from 'src/types/queries'
1314

1415
export const runAlertsActivityQuery = (
1516
orgID: string,
@@ -50,7 +51,7 @@ export const processResponse = ({
5051
cancel,
5152
}: CancelBox<RunQueryResult>): CancelBox<Row[]> => {
5253
const promise = queryPromise.then<Row[]>(resp => {
53-
if (resp.type !== 'SUCCESS') {
54+
if (resp.type !== RunQueryResponse.SUCCESS) {
5455
return Promise.reject(new Error(resp.message))
5556
}
5657

src/alerting/utils/history.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {MONITORING_BUCKET} from 'src/alerting/constants'
1616

1717
// Types
1818
import {State as EventViewerState} from 'src/eventViewer/components/EventViewer.reducer'
19+
import {RunQueryResponse} from 'src/types/queries'
1920

2021
import {
2122
CancelBox,
@@ -145,7 +146,7 @@ export const processResponse = ({
145146
cancel,
146147
}: CancelBox<RunQueryResult>): CancelBox<Row[]> => {
147148
const promise = queryPromise.then<Row[]>(resp => {
148-
if (resp.type !== 'SUCCESS') {
149+
if (resp.type !== RunQueryResponse.SUCCESS) {
149150
return Promise.reject(new Error(resp.message))
150151
}
151152

src/alerting/utils/statusEvents.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {MONITORING_BUCKET} from 'src/alerting/constants'
88

99
// Types
1010
import {CancelBox, StatusRow, File} from 'src/types'
11-
import {RunQueryResult} from 'src/shared/apis/query'
1211
import {Row} from 'src/types'
12+
import {RunQueryResult} from 'src/shared/apis/query'
13+
import {RunQueryResponse} from 'src/types/queries'
1314

1415
export const runStatusesQuery = (
1516
orgID: string,
@@ -46,7 +47,7 @@ export const processStatusesResponse = ({
4647
cancel,
4748
}: CancelBox<RunQueryResult>): CancelBox<Row[][]> => {
4849
const promise = queryPromise.then<Row[][]>(resp => {
49-
if (resp.type !== 'SUCCESS') {
50+
if (resp.type !== RunQueryResponse.SUCCESS) {
5051
return Promise.reject(new Error(resp.message))
5152
}
5253

src/shared/components/TimeSeries.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
CancelBox,
4646
} from 'src/types'
4747
import {event} from 'src/cloud/utils/reporting'
48+
import {RunQueryResponse} from 'src/types/queries'
4849

4950
interface QueriesState {
5051
files: string[] | null
@@ -278,12 +279,12 @@ class TimeSeries extends Component<Props, State> {
278279
const duration = Date.now() - startTime
279280

280281
for (const result of results) {
281-
if (result.type === 'UNKNOWN_ERROR') {
282+
if (result.type === RunQueryResponse.UNKNOWN_ERROR) {
282283
errorMessage = result.message
283284
throw new Error(result.message)
284285
}
285286

286-
if (result.type === 'RATE_LIMIT_ERROR') {
287+
if (result.type === RunQueryResponse.RATE_LIMIT_ERROR) {
287288
errorMessage = result.message
288289
notify(rateLimitReached(result.retryAfter))
289290

src/shared/utils/dataListening.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
// Utils
12
import {runQuery} from 'src/shared/apis/query'
23
import {LoadingState} from 'src/shared/components/DataListening/ConnectionInformation'
34

5+
// Types
6+
import {RunQueryResponse} from 'src/types/queries'
7+
48
export const TIMEOUT_MILLISECONDS = 60000
59
export const TIMER_WAIT = 1000
610

@@ -41,7 +45,7 @@ export const checkForData = async (orgID, bucket): Promise<LoadingState> => {
4145
try {
4246
const result = await runQuery(orgID, script).promise
4347

44-
if (result.type !== 'SUCCESS') {
48+
if (result.type !== RunQueryResponse.SUCCESS) {
4549
throw new Error(result.message)
4650
}
4751

src/timeMachine/apis/queryBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {DEFAULT_LIMIT} from 'src/shared/constants/queryBuilder'
2020
import {TimeRange, BuilderConfig} from 'src/types'
2121
import {CancelBox} from 'src/types/promises'
2222
import {pastThirtyDaysTimeRange} from 'src/shared/constants/timeRanges'
23+
import {RunQueryResponse} from 'src/types/queries'
2324

2425
const DEFAULT_TIME_RANGE: TimeRange = pastThirtyDaysTimeRange
2526

@@ -155,7 +156,7 @@ export function extractBoxedCol(
155156
colName: string
156157
): CancelBox<string[]> {
157158
const promise = resp.promise.then<string[]>(result => {
158-
if (result.type !== 'SUCCESS') {
159+
if (result.type !== RunQueryResponse.SUCCESS) {
159160
return Promise.reject(new Error(result.message))
160161
}
161162

src/types/queries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ export interface CustomTimeRange {
4949
upper: string
5050
type: 'custom'
5151
}
52+
53+
export enum RunQueryResponse {
54+
SUCCESS = 'SUCCESS',
55+
RATE_LIMIT_ERROR = 'RATE_LIMIT_ERROR',
56+
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
57+
}

src/variables/utils/ValueFetcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
Variable,
1717
} from 'src/types'
1818
import {CancelBox} from 'src/types/promises'
19+
import {RunQueryResponse} from 'src/types/queries'
1920

2021
const cacheKey = (
2122
url: string,
@@ -104,7 +105,7 @@ export class DefaultValueFetcher implements ValueFetcher {
104105
event('runQuery', {context: 'variables'})
105106

106107
const promise = request.promise.then(result => {
107-
if (result.type !== 'SUCCESS') {
108+
if (result.type !== RunQueryResponse.SUCCESS) {
108109
return Promise.reject(result.message)
109110
}
110111

src/writeData/components/fileUploads/CsvMethod.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import StatusIndicator from 'src/buckets/components/csvUploader/StatusIndicator'
1818
// Utils
1919
import {event} from 'src/cloud/utils/reporting'
2020
import {getErrorMessage} from 'src/utils/api'
21-
import {getOrg} from 'src/organizations/selectors'
21+
import {getOrg, isOrgIOx} from 'src/organizations/selectors'
2222
import {reportErrorThroughHoneyBadger} from 'src/shared/utils/errors'
2323
import {runQuery} from 'src/shared/apis/query'
24+
import {RunQueryResponse} from 'src/types/queries'
2425

2526
// Selectors
2627
import {
@@ -32,14 +33,15 @@ import {notify} from 'src/shared/actions/notifications'
3233
// Types
3334
import {RemoteDataState} from 'src/types'
3435

35-
const CsvMethod: FC = () => {
36+
export const CsvMethod: FC = () => {
3637
const [uploadState, setUploadState] = useState(RemoteDataState.NotStarted)
3738
const [uploadError, setUploadError] = useState('')
3839

3940
const {bucket} = useContext(WriteDataDetailsContext)
4041
const orgId = useSelector(getOrg)?.id
4142
const history = useHistory()
4243
const org = useSelector(getOrg)
44+
const orgIsIOx = useSelector(isOrgIOx)
4345

4446
const dispatch = useDispatch()
4547

@@ -96,24 +98,32 @@ const CsvMethod: FC = () => {
9698
controller.current
9799
).promise
98100

99-
if (resp.type === 'SUCCESS') {
101+
if (resp.type === RunQueryResponse.SUCCESS) {
100102
setUploadState(RemoteDataState.Done)
101103
return
102104
}
103-
if (resp.type === 'RATE_LIMIT_ERROR') {
105+
if (resp.type === RunQueryResponse.RATE_LIMIT_ERROR) {
104106
setUploadState(RemoteDataState.Error)
105-
setUploadError('Failed due to plan limits: read cardinality reached')
107+
if (orgIsIOx) {
108+
setUploadError(
109+
'Failed due to request exceeding read or write limits of plan'
110+
)
111+
} else {
112+
setUploadError(
113+
'Failed due to request exceeding read, write, or cardinality limits of plan'
114+
)
115+
}
106116
return
107117
}
108-
if (resp.type === 'UNKNOWN_ERROR') {
118+
if (resp.type === RunQueryResponse.UNKNOWN_ERROR) {
109119
const error = getErrorMessage(resp)
110120
throw new Error(error)
111121
}
112122
} catch (error) {
113123
handleError(error)
114124
}
115125
},
116-
[handleError, org?.id]
126+
[handleError, org?.id, orgIsIOx]
117127
)
118128

119129
const handleSeeUploadedData = () => {
@@ -173,5 +183,3 @@ const CsvMethod: FC = () => {
173183
</Panel>
174184
)
175185
}
176-
177-
export default CsvMethod

src/writeData/components/fileUploads/UploadDataDetailsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import CodeSnippet, {
1111
Provider as TemplateProvider,
1212
} from 'src/shared/components/CodeSnippet'
1313
import GetResources from 'src/resources/components/GetResources'
14-
import CsvMethod from 'src/writeData/components/fileUploads/CsvMethod'
14+
import {CsvMethod} from 'src/writeData/components/fileUploads/CsvMethod'
1515
import {LineProtocolTabs} from 'src/buckets/components/lineProtocol/configure/LineProtocolTabs'
1616
import {MarkdownRenderer} from 'src/shared/components/views/MarkdownRenderer'
1717

0 commit comments

Comments
 (0)