[appengine] Make ClientContext context getter nullable#329
[appengine] Make ClientContext context getter nullable#329martin-dehlan wants to merge 1 commit into
Conversation
The top-level `context` getter cast the service-scope lookup with `as ClientContext`. When called outside of a request handler the lookup returns `null`, so the cast threw a runtime error instead of yielding `null`. Change the getter to return `ClientContext?` and cast with `as ClientContext?` so callers can safely check for the absence of a request context. This is a breaking change, so the package version is bumped to 0.14.0. Fixes dart-lang#175 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I'm not really sure we want to do this. I think one should really know at the call-site if they are inside a request handler or not. This makes the common case more troublesome because now you need a ! for each legitimate use site, not really providing any benefit. |
Package publishingIf you have publishing permissions, you can use the links below to publish the changes after merging this PR.
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthUnused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with |
What
Changes the top-level
contextgetter inpackage:appengineto returnClientContext?instead ofClientContext.Why
The getter cast the service-scope lookup with
as ClientContext. When calledoutside of a request handler, the lookup returns
null, so the cast threw aruntime error instead of yielding
null. Returning a nullable type lets callerscheck for the absence of a request context safely.
Fixes #175
Notes
package version is bumped
0.13.12→0.14.0with a CHANGELOG entry.dart analyzepasses; no in-repo call sites or tests use the public getter.