- Introduces
HttpResponseExceptionandhttpResponseExceptionMiddleware.BadRequestExceptionandbadRequestMiddlewareare deprecated in favor ofHttpResponseExceptionandhttpResponseExceptionMiddleware, respectively. (They are aliased for backward compatibility.)
- Expanded
HttpResponseExceptionto support structured error reporting as per AIP-193.- Added
status(String?) anddetails(List<Map<String, Object?>>?) fields. - Added
toJson()method to serialize the error into a standard Google Cloud error payload. - Updated
toString()to includestatusanddetailswhen non-null. - Added factory constructors for common HTTP 4XX and 5XX status codes:
badRequest(400)unauthorized(401)forbidden(403)notFound(404)conflict(409)tooManyRequests(429)internalServerError(500)notImplemented(501)serviceUnavailable(503)gatewayTimeout(504)
- Added default
statusvalues for factories that map 1:1 to gRPC status codes (e.g.,unauthorizeddefaults to'UNAUTHENTICATED').
- Added
- Updated
httpResponseExceptionMiddlewareto leverageHttpResponseException.toJson()for JSON responses, returning a standard Google Cloud error payload. - Updated plain text errors to use
HttpResponseException.toString().
- Added
logSpanIdKey,logTraceKey, andlogTraceSampledKey.
-
BREAKING
structuredLogEntryremovedtraceIdparameter. Use the newpayloadparameter with thelogTraceKeyconstant as a key. -
Hardened structured log JSON serialization with automatic fallback mechanisms to safely handle native
toJson()implementations and circular references without failing. -
Added
CloudLogger(renamed fromRequestLogger).- Added optional
payloadandstackTracenamed parameters toCloudLoggerfunctions. CloudLoggeris no longer abstract and has a default implementation that prints to stdout.
- Added optional
- BREAKING Renamed
RequestLoggertoCloudLoggerand moved it topackage:google_cloud/general.dart. - Refactored HTTP logging logic to handle
spanIdandtraceSampled.
- Fix a bug where
projectIdFromGcloudConfig()used the incorrect gcloud shell command on Windows.
- Split the library into two main entry points:
package:google_cloud/general.dartfor general GCP features like project discovery, identity discovery, and core structured logging.package:google_cloud/http_serving.dartfor HTTP serving features like port discovery, shelf middleware, and signal handling.package:google_cloud/google_cloud.dartremains as an umbrella library exporting both.
- Renamed
projectIdFromEnvironment()toprojectIdFromEnvironmentVariables(). - Renamed
portEnvironmentKeytoportEnvironmentVariable. - Renamed
listenPort()tolistenPortFromEnvironment(). computeProjectId(),projectIdFromMetadataServer(), andserviceAccountEmailFromMetadataServer()now leverage a unified process-wide metadata cache.- Breaking Change: Local discovery strategies (environment variables,
credentials files, and
gcloudconfig) are no longer cached. - Breaking Change:
projectIdFromMetadataServer()andserviceAccountEmailFromMetadataServer()now throwMetadataServerException(which wrapsSocketException,TimeoutException, orClientException) when discovery fails. - Constants are now exported via
package:google_cloud/constants.dartand are no longer exported bypackage:google_cloud/google_cloud.dart. - Require Dart 3.9.
- Require
package:http^1.1.0.
- Added
getMetadataValue()(caching) andfetchMetadataValue()(non-caching) topackage:google_cloud/general.dart. - Added
projectIdFromCredentialsFile()to automatically discover project ID from the credentials JSON file. - Added
projectIdFromGcloudConfig()to automatically discover project ID from gcloud CLI configuration. - Added
serviceAccountEmailFromMetadataServer()to discover the default service account email. - Added
gceMetadataHostandgceMetadataUrlto interact with the metadata server. projectIdFromMetadataServer()now respects theGCE_METADATA_HOSTenvironment variable.- Added
refreshparameter tocomputeProjectId(),projectIdFromMetadataServer(), andserviceAccountEmailFromMetadataServer()to force re-discovery. - Added
clientparameter tocomputeProjectId(),projectIdFromMetadataServer(), andserviceAccountEmailFromMetadataServer()to allow providing a customhttp.Client. - Added
structuredLogEntry()for low-level structured log creation.
- First release replacing
package:gcp.