Skip to content

Commit 3e1d810

Browse files
fix: remove validation on flux before persistance (#6602)
* chore: update to use named exports * fix: remove flux validation on script saving so that users can save complicated flux as well as WIP scripts that may contain invalid flux * chore: remove test for invalud flux script
1 parent 0163499 commit 3e1d810

File tree

4 files changed

+3
-30
lines changed

4 files changed

+3
-30
lines changed

cypress/e2e/cloud/scriptQueryBuilder.scriptsCrud.test.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,7 @@ describe('Script Builder -- scripts crud on cloud', () => {
4949
})
5050
})
5151

52-
it('will not save an invalid flux query', () => {
53-
attemptSaveScript('invalid query')
54-
cy.log('should notify user of an error')
55-
cy.getByTestID('notification-error--dismiss').should('be.visible')
56-
cy.log('modal will stay open')
57-
cy.getByTestID('overlay--container').within(() => {
58-
cy.getByTestID('script-query-builder--cancel').should('be.visible')
59-
})
60-
})
61-
62-
it('will save a valid flux query', () => {
52+
it('will save a flux query', () => {
6353
saveScript(
6454
'from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)'
6555
)

src/dataExplorer/components/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ReactNode} from 'react'
22
import {ResourceType} from 'src/types/resources'
3-
import scriptResourceRegistration from 'src/dataExplorer/components/resources/types/script'
3+
import {scriptResourceRegistration} from 'src/dataExplorer/components/resources/types/script'
44

55
export const SCRIPT_EDITOR_PARAMS = '?fluxScriptEditor'
66

src/dataExplorer/components/resources/types/script/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const {getScript, patchScript, postScript} = CLOUD
1616
postScript: false,
1717
}
1818

19-
export default () => {
19+
export const scriptResourceRegistration = () => {
2020
return {
2121
type: ResourceType.Scripts,
2222
editor,

src/dataExplorer/context/persistance.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
ResourceConnectedQuery,
1616
} from 'src/dataExplorer/components/resources'
1717
import {isOrgIOx} from 'src/organizations/selectors'
18-
import {isValidFlux} from 'src/languageSupport/languages/flux/lspUtils'
1918

2019
interface CompositionStatus {
2120
synced: boolean // true == can modify session's schema
@@ -220,12 +219,6 @@ export const PersistanceProvider: FC = ({children}) => {
220219
]
221220
)
222221

223-
const buildMockStringifiedExtern = () => {
224-
// Only used for validation. Not persisted.
225-
// Note: new dataExplorer (a.k.a. scripts builder) only uses these variables
226-
return `option v = {timeRangeStart: -1h, timeRangeStop: now()}`
227-
}
228-
229222
const save = (language: LanguageType) => {
230223
if (!resource || !RESOURCES[resource.type]) {
231224
return Promise.resolve(null)
@@ -234,16 +227,6 @@ export const PersistanceProvider: FC = ({children}) => {
234227
resource.flux = query
235228
resource.language = language
236229

237-
const externForValidation = buildMockStringifiedExtern()
238-
if (
239-
language === LanguageType.FLUX &&
240-
!isValidFlux(`${externForValidation}\n${query}`)
241-
) {
242-
return Promise.reject(
243-
'Invalid flux script. Please check your query text.'
244-
)
245-
}
246-
247230
return RESOURCES[resource.type].persist(resource).then(data => {
248231
handleSetResource(data)
249232
setHasChanged(false)

0 commit comments

Comments
 (0)