Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(condo): DOMA-10226 add full stacked gql error traces #5243

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5c3a0bf
refactor(condo): DOMA-10227 remove ensure-error
pahaz Sep 16, 2024
b612423
refactor(condo): DOMA-10232 cleanup apolloErrorFormatter
pahaz Sep 17, 2024
e87a6a4
fix(condo): DOMA-10227 remove apollo-server-errors
pahaz Sep 17, 2024
232be31
fix(condo): DOMA-10227 apolloError style and tests
pahaz Sep 17, 2024
0f7ba06
feat(condo): DOMA-10226 add fullstack
pahaz Sep 18, 2024
b418ee9
feat(condo): DOMA-10226 add nested error throw
pahaz Sep 18, 2024
e8239f5
refactor(condo): DOMA-10226 hide internal and development fields for …
pahaz Sep 19, 2024
bb02acf
refactor(condo): DOMA-10226 catchErrorFrom, we want to display error …
pahaz Sep 19, 2024
27c57ff
refactor(condo): DOMA-10226 refactor catchErrorFrom
pahaz Sep 19, 2024
2a46416
refactor(condo): DOMA-10226 refactor validateQRCodeByTestClient add e…
pahaz Sep 19, 2024
7a131cf
refactor(condo): DOMA-10226 improve readability
pahaz Sep 20, 2024
85e06b2
refactor(condo): DOMA-10226 improve readability and fix mistakes
pahaz Sep 20, 2024
7fa02de
refactor(condo): DOMA-10226 add todo
pahaz Sep 20, 2024
d6636dd
Merge branch 'main' into errors-gql
pahaz Sep 23, 2024
8f7a004
fix(condo): DOMA-10226 process exit 1 if any error
pahaz Sep 24, 2024
e9857ca
chore(condo): DOMA-10226 rollback changes
pahaz Sep 24, 2024
3f415dc
refactor(condo): DOMA-10226 cleanup the logic and style
pahaz Sep 24, 2024
44f0469
refactor(condo): DOMA-10232 add default messageInterpolation and use …
pahaz Sep 24, 2024
7e84977
refactor(condo): DOMA-10232 cleanup
pahaz Sep 24, 2024
f570fa2
refactor(condo): DOMA-10342 prepare for removing ensure-error
pahaz Sep 30, 2024
3f8e1bd
refactor(condo): DOMA-10226 add SUB_GQL_ERROR type
pahaz Sep 30, 2024
aa58634
docs(condo): DOMA-10226 review fixes
pahaz Oct 1, 2024
4fadf06
refactor(condo): DOMA-10226 use clear naming
pahaz Oct 1, 2024
9afd386
refactor(condo): DOMA-10226 use GQLInternalErrorTypes
pahaz Oct 1, 2024
e56abdb
refactor(condo): DOMA-10226 use GQLInternalErrorTypes
pahaz Oct 1, 2024
bb404f2
fix(condo): DOMA-10226 use warn instead of throw new Error. Wait for …
pahaz Oct 1, 2024
6a67cf5
fix(condo): DOMA-10226 @Alllex202 comment about typo
pahaz Oct 1, 2024
a01992a
fix(condo): DOMA-10226 add `data` backward compatibility field
pahaz Oct 1, 2024
dcd0a08
fix(condo): DOMA-10226 add some missed messages
pahaz Oct 1, 2024
be4e122
fix(condo): DOMA-10226 add CI diff
pahaz Oct 1, 2024
5ce1139
fix(condo): DOMA-10226 change DEFAULT_LOCALE to en
pahaz Oct 1, 2024
b2bed91
fix(condo): DOMA-10226 fix CreateArtifact: Received non-retryable err…
pahaz Oct 1, 2024
d18b334
fix(condo): DOMA-10226 some tests
pahaz Oct 1, 2024
ae80ced
fix(condo): DOMA-10226 add .errors extraction and .data field for bac…
pahaz Oct 2, 2024
5dddc1d
refactor(condo): DOMA-10226 some error checks
pahaz Oct 2, 2024
060dd1b
fix(condo): DOMA-10370 add sendMessageToSupport docs
pahaz Oct 2, 2024
d2e4f41
chore(condo): DOMA-10370 fix docs text
pahaz Oct 2, 2024
1d0a68f
chore(condo): DOMA-10226 improve compatibility and DX
pahaz Oct 3, 2024
792b79c
chore(condo): DOMA-10226 improve tooling and DX
pahaz Oct 3, 2024
6b1c27c
chore(condo): DOMA-10226 use mock for @open-condo/locales/loader
pahaz Oct 3, 2024
ab575ff
chore(condo): DOMA-10226 add backward compatibility
pahaz Oct 3, 2024
bb63f54
chore(condo): DOMA-10368 change some tests compatibility
pahaz Oct 3, 2024
5e9c119
chore(condo): DOMA-10232 ci fixes
pahaz Oct 3, 2024
2a6a1ed
chore(condo): DOMA-10232 use expectToThrowGQLErrorToResult
pahaz Oct 3, 2024
56dd62e
chore(condo): DOMA-10232 use expectToThrowGQLErrorToResult
pahaz Oct 3, 2024
d3da221
chore(condo): DOMA-10232 fix random tests
pahaz Oct 3, 2024
b136869
fix(condo): DOMA-10232 failed exports tests
pahaz Oct 3, 2024
10c9b8e
chore(condo): DOMA-10232 linter
pahaz Oct 3, 2024
945d250
chore(condo): DOMA-10232 fix ci failing
pahaz Oct 4, 2024
c174c9d
chore(condo): DOMA-10232 fix ci failing
pahaz Oct 4, 2024
ff4f302
chore(condo): DOMA-10232 fix ci failing
pahaz Oct 4, 2024
31579ce
chore(condo): DOMA-10232 fix unstable sendDailyStatistics.spec.js test
pahaz Oct 4, 2024
9ffbb5b
chore(condo): DOMA-10232 fix unstable validateHelpers.spec.js test
pahaz Oct 4, 2024
7f00108
chore(condo): DOMA-10232 fix ci test
pahaz Oct 4, 2024
a793a0b
chore(condo): DOMA-10232 less aggressive check
pahaz Oct 4, 2024
cb81f8f
chore(condo): DOMA-10232 fix news tests
pahaz Oct 4, 2024
5e5482c
chore(condo): DOMA-10415 rollback strict checks
pahaz Oct 4, 2024
6ef9df9
fix(condo): DOMA-10415 missed locale task field
pahaz Oct 4, 2024
a42a014
fix(condo): DOMA-10415 rollback test locale
pahaz Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ TELEGRAM_EMPLOYEE_BOT_TOKEN=telegram-token
DISABLE_CAPTCHA=true
USE_LOCAL_FEATURE_FLAGS=true
NOTIFICATION__SEND_ALL_MESSAGES_TO_CONSOLE=true
NOTIFICATION__DISABLE_LOGGING=true
NOTIFICATION__DISABLE_LOGGING=false
TESTS_LOG_REQUEST_RESPONSE=true
WORKER_CONCURRENCY=50
2 changes: 1 addition & 1 deletion .github/workflows/_nodejs.condo.core.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: logs
name: logs-${{ inputs.domain_name }}-${{ env.GITHUB_RUN_ID }}-${{ env.GITHUB_RUN_NUMBER }}
path: |
./test_logs/*
*.log
Expand Down
77 changes: 12 additions & 65 deletions apps/address-service/domains/address/schema/Address.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
expectToThrowAuthenticationErrorToObjects,
expectToThrowAccessDeniedErrorToObj,
expectToThrowAccessDeniedErrorToObjects,
expectToThrowValidationFailureError,
} = require('@open-condo/keystone/test.utils')

const { OVERRIDING_ROOT } = require('@address-service/domains/address/constants')
Expand Down Expand Up @@ -201,7 +202,7 @@ describe('Address', () => {

describe('Overriding', () => {
test('throw an error if no field to override', async () => {
await catchErrorFrom(
await expectToThrowValidationFailureError(
async () => {
await createTestAddress(
adminClient,
Expand All @@ -211,23 +212,12 @@ describe('Address', () => {
},
)
},
(caught) => {
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
path: ['obj'],
data: expect.objectContaining({
messages: ['meta.data does not contains "nonExistingField" field'],
}),
})],
data: { obj: null },
}))
},
'meta.data does not contains "nonExistingField" field',
)
})

test('throw an error if try to override with the same value', async () => {
await catchErrorFrom(
await expectToThrowValidationFailureError(
async () => {
await createTestAddress(
adminClient,
Expand All @@ -237,23 +227,12 @@ describe('Address', () => {
},
)
},
(caught) => {
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
path: ['obj'],
data: expect.objectContaining({
messages: ['You trying to override field meta.data.someField with the same value'],
}),
})],
data: { obj: null },
}))
},
'You trying to override field meta.data.someField with the same value',
)
})

test('throw an error if try to override with array', async () => {
await catchErrorFrom(
await expectToThrowValidationFailureError(
async () => {
await createTestAddress(
adminClient,
Expand All @@ -263,23 +242,12 @@ describe('Address', () => {
},
)
},
(caught) => {
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
path: ['obj'],
data: expect.objectContaining({
messages: ['The "overrides" field must be an object'],
}),
})],
data: { obj: null },
}))
},
'The "overrides" field must be an object',
)
})

test('throw an error if try to override with string', async () => {
await catchErrorFrom(
await expectToThrowValidationFailureError(
async () => {
await createTestAddress(
adminClient,
Expand All @@ -289,23 +257,12 @@ describe('Address', () => {
},
)
},
(caught) => {
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
path: ['obj'],
data: expect.objectContaining({
messages: ['The "overrides" field must be an object'],
}),
})],
data: { obj: null },
}))
},
'The "overrides" field must be an object',
)
})

test('throw an error if try to override with number', async () => {
await catchErrorFrom(
await expectToThrowValidationFailureError(
async () => {
await createTestAddress(
adminClient,
Expand All @@ -315,18 +272,7 @@ describe('Address', () => {
},
)
},
(caught) => {
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
path: ['obj'],
data: expect.objectContaining({
messages: ['The "overrides" field must be an object'],
}),
})],
data: { obj: null },
}))
},
'The "overrides" field must be an object',
)
})

Expand All @@ -342,6 +288,7 @@ describe('Address', () => {
)
},
(caught) => {
// TODO(pahaz): DOMA-10348 refactor and use `expectToThrowValidationFailureError`
expect(caught).toEqual(expect.objectContaining({
errors: [expect.objectContaining({
name: 'ValidationFailureError',
Expand Down
1 change: 1 addition & 0 deletions apps/condo/domains/acquiring/routes/paymentLinkRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class PaymentLinkRouter {
ip,
PAYMENT_LINK_WINDOW_SIZE,
MAX_PAYMENT_LINK_REQUEST_BY_WINDOW,
{ req },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ const ERRORS = {

const redisGuard = new RedisGuard()

const checkLimits = async (userId) => {
const checkLimits = async (userId, context) => {
await redisGuard.checkCustomLimitCounters(
`calculate_fee_for_receipt:user:${userId}`,
RESIDENT_CALCULATE_FEE_FOR_RECEIPT_WINDOW_IN_SEC,
MAX_RESIDENT_CALCULATE_FEE_FOR_RECEIPT_WINDOW_IN_SEC_CALLS_BY_WINDOW_SEC,
context,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const { faker } = require('@faker-js/faker')
const Big = require('big.js')

const { expectToThrowGQLError, catchErrorFrom } = require('@open-condo/keystone/test.utils')
const { expectToThrowGQLError, expectToThrowGQLErrorToResult } = require('@open-condo/keystone/test.utils')

const { GQL_ERRORS: { PAYMENT_AMOUNT_LESS_THAN_MINIMUM } } = require('@condo/domains/acquiring/constants/errors')
const { calculateFeeForReceiptByTestClient } = require('@condo/domains/acquiring/utils/testSchema')
Expand All @@ -19,8 +19,8 @@ describe('CalculateFeeForReceiptService', () => {
await utils.init()
await utils.updateAcquiringIntegration({
explicitFeeDistributionSchema: [
{ 'recipient':'acquiring', 'percent':'1.0' },
{ 'recipient':'service', 'percent':'0.2' },
{ 'recipient': 'acquiring', 'percent': '1.0' },
{ 'recipient': 'service', 'percent': '0.2' },
],
})
})
Expand All @@ -38,7 +38,7 @@ describe('CalculateFeeForReceiptService', () => {
test('Check calculations for implicit fees', async () => {
const [[receipt]] = await utils.createReceipts()
await utils.updateAcquiringContext({
implicitFeeDistributionSchema: [{ 'recipient':'organization', 'percent':'1.2' }],
implicitFeeDistributionSchema: [{ 'recipient': 'organization', 'percent': '1.2' }],
})
const amount = '300'
const [result] = await calculateFeeForReceiptByTestClient(utils.clients.resident, { receipt: { id: receipt.id }, amount })
Expand All @@ -51,20 +51,17 @@ describe('CalculateFeeForReceiptService', () => {
test('Receipt must exist', async () => {
const missingReceiptId = faker.datatype.uuid()
const amount = '300'
await catchErrorFrom(async () => {
await expectToThrowGQLErrorToResult(async () => {
await calculateFeeForReceiptByTestClient(utils.clients.resident, { receipt: { id: missingReceiptId }, amount })
}, ({ errors }) => {
expect(errors).toMatchObject([{
message: `Cannot find specified BillingReceipt with id ${missingReceiptId}`,
path: ['result'],
extensions: {
query: 'calculateFeeForReceipt',
variable: ['data', 'receipt', 'id'],
code: 'BAD_USER_INPUT',
type: 'CANNOT_FIND_ALL_BILLING_RECEIPTS',
message: 'Cannot find specified BillingReceipt with id {missingReceiptId}',
},
}])
}, {
query: 'calculateFeeForReceipt',
variable: ['data', 'receipt', 'id'],
code: 'BAD_USER_INPUT',
type: 'CANNOT_FIND_ALL_BILLING_RECEIPTS',
message: 'Cannot find specified BillingReceipt with id {missingReceiptId}',
messageInterpolation: {
missingReceiptId,
},
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const dayjs = require('dayjs')

const {
makeLoggedInAdminClient, makeClient, expectToThrowAuthenticationErrorToResult, catchErrorFrom,
expectToThrowAccessDeniedErrorToResult,
expectToThrowAccessDeniedErrorToResult, expectToThrowGQLErrorToResult,
} = require('@open-condo/keystone/test.utils')

const { CONTEXT_FINISHED_STATUS } = require('@condo/domains/acquiring/constants/context')
Expand Down Expand Up @@ -431,26 +431,13 @@ describe('CreatePaymentByLinkService', () => {

const payload = { qrCode }

await catchErrorFrom(async () => {
await expectToThrowGQLErrorToResult(async () => {
await createPaymentByLinkByTestClient(user, payload)
}, (error) => {
const { errors } = error
expect(errors).toEqual([
expect.objectContaining({
message: '[error] Unable to validateQRCode',
originalError: expect.objectContaining({
errors: [expect.objectContaining({
name: 'GQLError',
message: 'Provided bank account is not in the system',
extensions: expect.objectContaining({
mutation: 'validateQRCode',
code: 'BAD_USER_INPUT',
message: 'Provided bank account is not in the system',
}),
})],
}),
}),
])
}, {
mutation: 'validateQRCode',
code: 'BAD_USER_INPUT',
type: 'WRONG_FORMAT',
message: 'Provided bank account is not in the system',
})

})
Expand Down Expand Up @@ -522,6 +509,7 @@ describe('CreatePaymentByLinkService', () => {
advancedAt: dayjs().toISOString(),
})

// TODO(pahaz): DOMA-10368 use expectToThrowGQLErrorToResult
await catchErrorFrom(async () => {
await createPaymentByLinkByTestClient(admin, { qrCode })
}, (error) => {
Expand Down Expand Up @@ -570,6 +558,7 @@ describe('CreatePaymentByLinkService', () => {
advancedAt: dayjs().toISOString(),
})

// TODO(pahaz): DOMA-10368 use expectToThrowGQLErrorToResult
await catchErrorFrom(async () => {
await createPaymentByLinkByTestClient(admin, { qrCode })
}, (error) => {
Expand Down Expand Up @@ -618,6 +607,7 @@ describe('CreatePaymentByLinkService', () => {
advancedAt: dayjs().toISOString(),
})

// TODO(pahaz): DOMA-10368 use expectToThrowGQLErrorToResult
await catchErrorFrom(async () => {
await createPaymentByLinkByTestClient(admin, { qrCode })
}, (error) => {
Expand Down Expand Up @@ -682,6 +672,7 @@ describe('CreatePaymentByLinkService', () => {
advancedAt: dayjs().toISOString(),
})

// TODO(pahaz): DOMA-10368 use expectToThrowGQLErrorToResult
await catchErrorFrom(async () => {
await createPaymentByLinkByTestClient(admin, { qrCode })
}, (error) => {
Expand Down
3 changes: 2 additions & 1 deletion apps/condo/domains/acquiring/schema/ExportPaymentsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const ERRORS = {
code: BAD_USER_INPUT,
type: WRONG_FORMAT,
message: 'Invalid format of "sender" field value. {details}',
correctExample: '{ dv: 1, fingerprint: \'example-fingerprint-alphanumeric-value\'}',
correctExample: '{ "dv": 1, "fingerprint": "uniq-device-or-container-id" }',
messageInterpolation: { details: 'Please, check the example for details' },
},
NOTHING_TO_EXPORT: {
// TODO(pahaz): mutation! cahnge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const ERRORS = {
code: BAD_USER_INPUT,
type: WRONG_FORMAT,
message: 'Invalid format of "sender" field value. {details}',
correctExample: '{ dv: 1, fingerprint: \'example-fingerprint-alphanumeric-value\'}',
correctExample: '{ "dv": 1, "fingerprint": "uniq-device-or-container-id" }',
messageInterpolation: { details: 'Please, check the example for details' },
},
ACQUIRING_INTEGRATION_CONTEXT_IS_DELETED: {
mutation: 'generatePaymentLink',
Expand Down
Loading
Loading