Skip to content

[Bug]: Pyramid instrumentation uses non-existent pyramid/webob API #819

@ZaiZu2

Description

@ZaiZu2

Problem Description

Hello,

when unhandled error is raised within a pyramid endpoint, Instana tween tries to look up Response.exception attribute which does not exist, obscuring the original error and also breaking the response.

2025-11-10 10:00:15,248 ERROR [gunicorn.error][MainThread] Error handling request /health/readiness/
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 134, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/sync.py", line 177, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyramid/router.py", line 270, in __call__
    response = self.execution_policy(environ, self)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyramid/router.py", line 276, in default_execution_policy
    return router.invoke_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyramid/router.py", line 245, in invoke_request
    response = handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/instana/instrumentation/pyramid.py", line 83, in __call__
    if response.exception:
       ^^^^^^^^^^^^^^^^^^
AttributeError: 'Response' object has no attribute 'exception'
10.244.208.127 - - [10/Nov/2025:10:00:15 +0000] "GET /health/readiness/ HTTP/1.1" 500 0 "-" "-"

My knowledge of pyramid is limited, but after some digging I believe exception arg simply does not exist in Response object. Here are pyramid docs on Response - no mention of exception attribute.:
https://docs.pylonsproject.org/projects/pyramid/en/latest/api/response.html#pyramid-response

This happens on pyramid==2.0.2, webob==1.8.9 and instana==3.9.2.

Minimal, Complete, Verifiable, Example

No response

Python Version

Python 3.11

Python Modules

Package                            Version
---------------------------------- --------------
alembic                            1.13.2
arrow                              1.3.0
attrs                              25.3.0
autowrapt                          1.0
babel                              2.16.0
boto3                              1.35.21
botocore                           1.35.99
certifi                            2025.10.5
charset-normalizer                 3.4.4
deprecated                         1.2.18
fluent-logger                      0.11.1
fysom                              2.1.6
gateway                            0.0.0
greenlet                           3.1.0
gunicorn                           23.0.0
hupper                             1.12.1
idna                               3.11
importlib-metadata                 8.7.0
instana                            3.9.2
isodate                            0.7.2
jmespath                           1.0.1
jsonschema                         4.23.0
jsonschema-path                    0.3.4
jsonschema-specifications          2025.4.1
lazy-object-proxy                  1.11.0
mako                               1.3.10
markupsafe                         3.0.2
more-itertools                     10.7.0
msgpack                            1.1.0
openapi-core                       0.19.5
openapi-schema-validator           0.6.3
openapi-spec-validator             0.7.1
opentelemetry-api                  1.38.0
opentelemetry-semantic-conventions 0.59b0
packaging                          25.0
parse                              1.20.2
pastedeploy                        3.1.0
pathable                           0.4.4
plaster                            1.1.2
plaster-pastedeploy                1.0.1
psycopg2                           2.9.4
pyramid                            2.0.2
pyramid-openapi3                   0.20.1
pyramid-tm                         2.6
python-dateutil                    2.9.0.post0
pyyaml                             6.0.3
referencing                        0.36.2
requests                           2.32.5
rfc3339-validator                  0.1.4
rpds-py                            0.24.0
s3transfer                         0.10.4
setuptools                         80.0.1
six                                1.17.0
sqlalchemy                         2.0.35
sqlalchemy-utils                   0.41.2
transaction                        5.0
translationstring                  1.4
types-python-dateutil              2.9.0.20241206
typing-extensions                  4.15.0
urllib3                            2.5.0
venusian                           3.1.1
webob                              1.8.9
werkzeug                           3.1.1
wrapt                              2.0.1
zipp                               3.23.0
zope-deprecation                   5.1
zope-interface                     7.2
zope-sqlalchemy                    3.1

Python Environment

-

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions