Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis_sge_konnector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
enedis_sge_konnector
Commits
2df90c7c
Commit
2df90c7c
authored
1 year ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
add service ID
parent
82c80082
No related branches found
No related tags found
1 merge request
!54
fix: throw vendor down when request is rejected
Pipeline
#93833
passed
1 year ago
Stage: test
Stage: build
Stage: update-instances
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/contractVerification.js
+6
-2
6 additions, 2 deletions
src/core/contractVerification.js
src/helpers/catch.js
+5
-3
5 additions, 3 deletions
src/helpers/catch.js
with
11 additions
and
5 deletions
src/core/contractVerification.js
+
6
−
2
View file @
2df90c7c
...
...
@@ -46,7 +46,11 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
throw
new
Error
(
errors
.
CAPTCHA_RESOLUTION_FAILED
)
})
catchRequestReject
(
response
.
body
)
try
{
catchRequestReject
(
response
.
body
)
}
catch
(
error
)
{
throw
new
Error
(
errors
.
CAPTCHA_RESOLUTION_FAILED
)
}
const
parsedReply
=
await
xml2js
.
parseStringPromise
(
response
.
body
,
{
tagNameProcessors
:
[
parseTags
],
...
...
@@ -82,7 +86,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
section
:
'
verifyContract
'
,
},
})
if
(
parsedReply
.
Envelope
.
Body
.
Fault
)
{
if
(
parsedReply
?
.
Envelope
?
.
Body
?
.
Fault
)
{
log
(
'
error
'
,
`Enedis issue
${
parsedReply
.
Envelope
.
Body
.
Fault
.
detail
.
erreur
.
resultat
.
$
.
code
}
:
${
parsedReply
.
Envelope
.
Body
.
Fault
.
faultstring
}
`
...
...
This diff is collapsed.
Click to expand it.
src/helpers/catch.js
+
5
−
3
View file @
2df90c7c
const
{
log
,
errors
}
=
require
(
'
cozy-konnector-libs
'
)
const
{
log
}
=
require
(
'
cozy-konnector-libs
'
)
/**
* Throw a
VENDOR_DOWN
error if the response contains a "Request Rejected"
* Throw a
n
error if the response contains a "Request Rejected"
* Enedis might send a 429 status but the F5 always transform it to a 200
* @param {string} response
* @example <html><head><title>Request Rejected</title></head>
...
...
@@ -9,9 +9,11 @@ const { log, errors } = require('cozy-konnector-libs')
*/
function
catchRequestReject
(
response
)
{
if
(
response
.
includes
(
'
Request Rejected
'
))
{
const
supportID
=
response
.
replace
(
/
\D
/g
,
''
)
log
(
'
debug
'
,
response
.
slice
(
0
,
100
))
log
(
'
error
'
,
`Support ID :
${
supportID
}
`
)
log
(
'
error
'
,
'
Request Rejected
'
)
throw
new
Error
(
errors
.
VENDOR_DOWN
)
throw
new
Error
(
'
Request Rejected
'
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
cfa0bbc0
·
1 year ago
mentioned in commit
cfa0bbc0
mentioned in commit cfa0bbc02b4deb0ac4b42dd14df3cd534a596b65
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment