Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
c7e4fa23
Commit
c7e4fa23
authored
5 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-fix-timeout-error-messages' into 'dev'
F fix timeout error messages See merge request
!169
parents
2f7cb996
84443119
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!175
BUG: Request responses without the "Set-Cookie" header no longer overwrite the...
,
!169
F fix timeout error messages
Pipeline
#59663
passed
4 months ago
Stage: setup
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
3
Pipelines
24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+5
-1
5 additions, 1 deletion
CHANGELOG.md
src/linkahead/exceptions.py
+20
-6
20 additions, 6 deletions
src/linkahead/exceptions.py
unittests/test_error_handling.py
+24
-1
24 additions, 1 deletion
unittests/test_error_handling.py
with
49 additions
and
8 deletions
CHANGELOG.md
+
5
−
1
View file @
c7e4fa23
...
@@ -27,7 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
...
@@ -27,7 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`authentication/interface/on_response()`
does not overwrite
`authentication/interface/on_response()`
does not overwrite
`auth_token`
if new value is
`None`
`auth_token`
if new value is
`None`
*
[
#119
](
https://gitlab.com/linkahead/linkahead-pylib/-/issues/119
)
*
[
#119
](
https://gitlab.com/linkahead/linkahead-pylib/-/issues/119
)
The diff returned by compare_entities now uses id instead of name as key if either property does not have a name
The diff returned by compare_entities now uses id instead of name as
key if either property does not have a name
*
[
#87
](
https://gitlab.com/linkahead/linkahead-pylib/-/issues/87
)
`XMLSyntaxError`
messages when parsing (incomplete) responses in
case of certain connection timeouts.
### Security ###
### Security ###
...
...
This diff is collapsed.
Click to expand it.
src/linkahead/exceptions.py
+
20
−
6
View file @
c7e4fa23
...
@@ -94,12 +94,26 @@ class HTTPServerError(LinkAheadException):
...
@@ -94,12 +94,26 @@ class HTTPServerError(LinkAheadException):
"""
HTTPServerError represents 5xx HTTP server errors.
"""
"""
HTTPServerError represents 5xx HTTP server errors.
"""
def
__init__
(
self
,
body
):
def
__init__
(
self
,
body
):
xml
=
etree
.
fromstring
(
body
)
try
:
error
=
xml
.
xpath
(
'
/Response/Error
'
)[
0
]
# This only works if the server sends a valid XML
msg
=
error
.
get
(
"
description
"
)
# response. Then it can be parsed for more information.
xml
=
etree
.
fromstring
(
body
)
if
error
.
text
is
not
None
:
if
xml
.
xpath
(
'
/Response/Error
'
):
msg
=
msg
+
"
\n\n
"
+
error
.
text
error
=
xml
.
xpath
(
'
/Response/Error
'
)[
0
]
msg
=
error
.
get
(
"
description
"
)
if
error
.
get
(
"
description
"
)
is
not
None
else
""
if
error
.
text
is
not
None
:
if
msg
:
msg
=
msg
+
"
\n\n
"
+
error
.
text
else
:
msg
=
error
.
text
else
:
# Valid XML, but no error information
msg
=
body
except
etree
.
XMLSyntaxError
:
# Handling of incomplete responses, e.g., due to timeouts,
# c.f. https://gitlab.com/linkahead/linkahead-pylib/-/issues/87.
msg
=
body
LinkAheadException
.
__init__
(
self
,
msg
)
LinkAheadException
.
__init__
(
self
,
msg
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_error_handling.py
+
24
−
1
View file @
c7e4fa23
...
@@ -30,7 +30,7 @@ import linkahead as db
...
@@ -30,7 +30,7 @@ import linkahead as db
from
linkahead.common.models
import
raise_errors
from
linkahead.common.models
import
raise_errors
from
linkahead.exceptions
import
(
AuthorizationError
,
from
linkahead.exceptions
import
(
AuthorizationError
,
EntityDoesNotExistError
,
EntityError
,
EntityDoesNotExistError
,
EntityError
,
EntityHasNoDatatypeError
,
EntityHasNoDatatypeError
,
HTTPServerError
,
TransactionError
,
UniqueNamesError
,
TransactionError
,
UniqueNamesError
,
UnqualifiedParentsError
,
UnqualifiedParentsError
,
UnqualifiedPropertiesError
)
UnqualifiedPropertiesError
)
...
@@ -315,3 +315,26 @@ def test_container_with_faulty_elements():
...
@@ -315,3 +315,26 @@ def test_container_with_faulty_elements():
# record raises both of them
# record raises both of them
assert
(
isinstance
(
err
,
UnqualifiedParentsError
)
or
assert
(
isinstance
(
err
,
UnqualifiedParentsError
)
or
isinstance
(
err
,
UnqualifiedPropertiesError
))
isinstance
(
err
,
UnqualifiedPropertiesError
))
def
test_incomplete_server_error_response
():
"""
The reason behind https://gitlab.com/linkahead/linkahead-pylib/-/issues/87.
"""
# Case 1: Response is no XML at all
err
=
HTTPServerError
(
"
Bla
"
)
assert
str
(
err
)
==
"
Bla
"
# Case 2: Response is an incomplete XML, e.g. due to very unlucky timeout
err
=
HTTPServerError
(
"
<incomplete>XML</inc
"
)
assert
str
(
err
)
==
"
<incomplete>XML</inc
"
# Case 3: Response is complete XML but doesn't have response and or error information
err
=
HTTPServerError
(
"
<complete>XML</complete>
"
)
assert
str
(
err
)
==
"
<complete>XML</complete>
"
# Case 4: Response is an XML response but the error is lacking a description
err
=
HTTPServerError
(
"
<Response><Error>complete error</Error></Response>
"
)
assert
str
(
err
)
==
"
complete error
"
# Case 5: Healthy error Response
err
=
HTTPServerError
(
"
<Response><Error description=
'
Error
'
>complete error</Error></Response>
"
)
assert
str
(
err
)
==
"
Error
\n\n
complete error
"
This diff is collapsed.
Click to expand it.
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