Skip to content

Dart#1255

Open
jhuleatt wants to merge 1 commit intomainfrom
dart-launch
Open

Dart#1255
jhuleatt wants to merge 1 commit intomainfrom
dart-launch

Conversation

@jhuleatt
Copy link
Copy Markdown
Collaborator

@jhuleatt jhuleatt commented Apr 2, 2026

No description provided.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@jhuleatt jhuleatt requested a review from egilmorez April 2, 2026 13:38
Comment on lines +33 to +56
runs-on: ubuntu-latest
strategy:
matrix:
dart-version:
- "3.11.4"
steps:
- uses: actions/checkout@v4

- name: Set up Dart ${{ matrix.dart-version }}
uses: dart-lang/setup-dart@v1.6.0
with:
sdk: ${{ matrix.dart-version }}

- name: HTTPS Time Server - Install dependencies
working-directory: ./Dart/quickstarts/https-time-server
run: dart pub get

- name: HTTPS Time Server - Format
working-directory: ./Dart/quickstarts/https-time-server
run: dart format --set-exit-if-changed .

- name: HTTPS Time Server - Analyze
working-directory: ./Dart/quickstarts/https-time-server
run: dart analyze .

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Dart-based HTTPS time server quickstart for Firebase Cloud Functions. The changes include the core function logic in bin/server.dart, dependency management in pubspec.yaml, Firebase configuration in firebase.json, a .gitignore file, and comprehensive documentation in README.md for the quickstart, along with an update to the root README.md. Feedback from the review suggests correcting a cURL command's line continuation in the quickstart's README.md, adding error handling for invalid date formats in bin/server.dart to prevent server errors, and removing unused dart_firebase_admin and google_cloud_firestore dependencies from pubspec.yaml to improve project efficiency.

Comment on lines +75 to +77
curl -H 'Content-Type: application/json' /
-d '{"format": "MMMM d yyyy, h:mm:ss a"}' /
<function url>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cURL command uses / for line continuation, which is incorrect for bash (it should be \). Additionally, / is a path separator, so this command would likely fail or behave unexpectedly when executed.

Suggested change
curl -H 'Content-Type: application/json' /
-d '{"format": "MMMM d yyyy, h:mm:ss a"}' /
<function url>
curl -H 'Content-Type: application/json' \
-d '{"format": "MMMM d yyyy, h:mm:ss a"}' \
<function url>

Comment on lines +77 to +79
final formattedDate = DateFormat(format).format(DateTime.now());
print('Sending formatted date: $formattedDate');
return Response.ok(formattedDate);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The DateFormat constructor and format method can throw an exception (such as FormatException or ArgumentError) if the provided format string is invalid. Since the format can be supplied by the user via query parameters or the request body, this call should be wrapped in a try-catch block to return a 400 Bad Request instead of allowing the function to crash with a 500 Internal Server Error.

      try {
        final formattedDate = DateFormat(format).format(DateTime.now());
        print('Sending formatted date: $formattedDate');
        return Response.ok(formattedDate);
      } catch (e) {
        return Response.badRequest(body: 'Invalid date format pattern.');
      }

Comment on lines +13 to +22
dart_firebase_admin:
git:
url: https://github.com/firebase/firebase-admin-dart
path: packages/dart_firebase_admin
ref: main
google_cloud_firestore:
git:
url: https://github.com/firebase/firebase-admin-dart
path: packages/google_cloud_firestore
ref: main
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The dependencies dart_firebase_admin and google_cloud_firestore are not used in this quickstart. Removing unused dependencies keeps the sample focused and reduces the installation time for users. You should also remove the corresponding entries in the dependency_overrides section (lines 29-39).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants