Skip to content

[appengine] Make ClientContext context getter nullable#329

Open
martin-dehlan wants to merge 1 commit into
dart-lang:mainfrom
martin-dehlan:fix-nullable-client-context
Open

[appengine] Make ClientContext context getter nullable#329
martin-dehlan wants to merge 1 commit into
dart-lang:mainfrom
martin-dehlan:fix-nullable-client-context

Conversation

@martin-dehlan

Copy link
Copy Markdown
Contributor

What

Changes the top-level context getter in package:appengine to return
ClientContext? instead of ClientContext.

Why

The 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. Returning a nullable type lets callers
check for the absence of a request context safely.

Fixes #175

Notes

  • This is a breaking API change (non-nullable → nullable return type), so the
    package version is bumped 0.13.120.14.0 with a CHANGELOG entry.
  • dart analyze passes; no in-repo call sites or tests use the public getter.

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>
@martin-dehlan martin-dehlan requested a review from a team as a code owner June 14, 2026 12:29
@google-cla

google-cla Bot commented Jun 14, 2026

Copy link
Copy Markdown

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.

@sigurdm

sigurdm commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions

Copy link
Copy Markdown

Package publishing

If you have publishing permissions, you can use the links below to publish the changes after merging this PR.

Package Version Status Publish tag (post-merge)
package:appengine 0.14.0 ready to publish appengine-v0.14.0
package:gcloud 0.9.0 already published at pub.dev
package:native_synchronization 0.3.1 already published at pub.dev
package:timezone 0.11.0 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@github-actions

Copy link
Copy Markdown

PR Health

Unused Dependencies ✔️
Package Status
appengine ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
appengine Breaking 0.13.12 0.14.0 0.14.0 ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

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.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

Coverage ✔️
File Coverage
pkgs/appengine/lib/appengine.dart 💚 13 %

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 skip-coverage-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/timezone/example/example.dart
pkgs/timezone/test/datetime_browser_test.dart
pkgs/timezone/test/datetime_test.dart
pkgs/timezone/test/datetime_test_no_database.dart
pkgs/timezone/test/two_way_test.dart
pkgs/timezone/test/zicfile_test.dart
pkgs/timezone/test/zone_tab_test.dart
pkgs/timezone/tool/encode_dart.dart
pkgs/timezone/tool/encode_tzf.dart
pkgs/timezone/tool/get.dart
pkgs/timezone/tool/test_random.dart
pkgs/timezone/tool/zone_dump.dart

This check can be disabled by tagging the PR with skip-license-check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientContext get context should be nullable

3 participants