Skip to content

Commit

Permalink
Remove redundant check and better error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Aug 23, 2023
1 parent 73c231d commit 0edf7f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ describe.each(flagValueTestParameters)(
)

const expectedErrorMsg = flagValue
? 'Transient server error: Concurrent editing occurred. Please refresh the page to continue.'
? 'Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.'
: 'Transient server error: attempted to modify un-modifiable field(s): updatedAt. Please refresh the page to continue.'

expect(updateResult.errors[0].message).toBe(expectedErrorMsg)
Expand Down Expand Up @@ -414,7 +414,7 @@ describe.each(flagValueTestParameters)(
)

const expectedErrorMsg = flagValue
? 'Transient server error: Concurrent editing occurred. Please refresh the page to continue.'
? 'Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.'
: 'Transient server error: attempted to modify un-modifiable field(s): stateCode,stateNumber,createdAt,updatedAt. Please refresh the page to continue.'

expect(updateResult.errors[0].message).toBe(expectedErrorMsg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export function updateHealthPlanFormDataResolver(
}

// Can't update a submission that is locked or resubmitted
if (!['DRAFT', 'UNLOCKED'].includes(contractWithHistory.status)) {
if (!contractWithHistory.draftRevision) {
const errMessage = `Package is not in editable state: ${input.pkgID} status: ${contractWithHistory.status}`
logError('updateHealthPlanFormData', errMessage)
setErrorAttributesOnActiveSpan(errMessage, span)
Expand All @@ -170,25 +170,12 @@ export function updateHealthPlanFormDataResolver(
})
}

// If contract is draft and draft revision does not exist, then possibly:
// - contract was mislabeled labelled DRAFT in the parsing functions.
// - something happened in the converter functions to not add draft revision.
// - there were no revisions without submitted info.
if (!contractWithHistory.draftRevision) {
const errMessage = `Issue finding a draft revision for contract id ${input.pkgID}. Message: Draft revision not found}`
throw new GraphQLError(errMessage, {
extensions: {
code: 'INTERNAL_SERVER_ERROR',
},
})
}

// If updatedAt does not match concurrent editing occurred.
if (
contractWithHistory.draftRevision.updatedAt.getTime() !==
unlockedFormData.updatedAt.getTime()
) {
const errMessage = `Transient server error: Concurrent editing occurred. Please refresh the page to continue.`
const errMessage = `Concurrent update error: The data you are trying to modify has changed since you last retrieved it. Please refresh the page to continue.`
logError('updateHealthPlanFormData', errMessage)
setErrorAttributesOnActiveSpan(errMessage, span)
throw new UserInputError(errMessage)
Expand Down

0 comments on commit 0edf7f3

Please sign in to comment.