Skip to content

fix: Fail on start() instead of silent ignore; encode string during error returns#85

Merged
knative-prow[bot] merged 1 commit intoknative-extensions:mainfrom
gauron99:push-qpvtwwrkvoxt
May 6, 2026
Merged

fix: Fail on start() instead of silent ignore; encode string during error returns#85
knative-prow[bot] merged 1 commit intoknative-extensions:mainfrom
gauron99:push-qpvtwwrkvoxt

Conversation

@gauron99
Copy link
Copy Markdown
Contributor

@gauron99 gauron99 commented May 6, 2026

add try/except wrapper for start() method to error on failed start; encode strings to bytes in exception returns

observed errors:

silent fail on start()

Lifespan failure — hypercorn silently continues with broken state:

INFO:root:Functions middleware invoking user function
[2026-05-06 07:40:51 +0200] [219186] [WARNING] ASGI Framework Lifespan error, continuing without
Lifespan support
WARNING:hypercorn.error:ASGI Framework Lifespan error, continuing without Lifespan support
[2026-05-06 07:40:51 +0200] [219186] [INFO] Running on http://127.0.0.1:8080 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://127.0.0.1:8080 (CTRL + C to quit)

this will appear to run the function just fine (for a second) and then Error: timed out waiting for function to be ready for 1m0s BUT the function is still listening!

on curl you get

[2026-05-06 09:57:21 +0200] [648316] [ERROR] Error in ASGI Framework
Traceback (most recent call last):
  File ".../func_python/http.py", line 134, in __call__
    await self.f.handle(scope, receive, send)
  File ".../function/func.py", line 85, in handle
    "database": self.db.db_path,
                ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'db_path'

exception error

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File ".../func_python/http.py", line 136, in __call__
      await send_exception(send, 500, f"Error: {e}")
    File ".../func_python/http.py", line 188, in send_exception
      await send({
          'type': 'http.response.body', 'body': message,
      })
    File ".../hypercorn/protocol/http_stream.py", line 193, in app_send
      Body(stream_id=self.stream_id, data=bytes(message.get("body", b"")))
                                          ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  TypeError: string argument without an encoding

@knative-prow knative-prow Bot requested review from lkingland and matzew May 6, 2026 07:59
@knative-prow knative-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 6, 2026
@gauron99 gauron99 changed the title Fail on start() errors; encode string during error returns fix: Fail on start() instead of silent ignore; encode string during error returns May 6, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, matejvasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [gauron99,matejvasek]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot merged commit e0720d5 into knative-extensions:main May 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants