Skip to content

htmx sample#1284

Open
jhuleatt wants to merge 9 commits into
dart-launchfrom
dart-htmx
Open

htmx sample#1284
jhuleatt wants to merge 9 commits into
dart-launchfrom
dart-htmx

Conversation

@jhuleatt
Copy link
Copy Markdown
Collaborator

No description provided.

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 Dart-based Firebase Cloud Function that implements a contact management interface using HTMX and Pico CSS. It includes the necessary configuration files, dependencies, and server logic for viewing and editing contact information stored in Firestore. The code review identified several critical issues, including the use of an undefined 'fireUp' function, an invalid Dart SDK version constraint, and an incorrect HTMX version reference. Additional feedback suggests improving the robustness of the implementation by handling Firestore data nullability more safely, avoiding hardcoded document IDs, and adding validation for user-submitted form data.

}

void main(List<String> args) {
fireUp(args, (firebase) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The function fireUp is not defined in this file nor is it imported from any of the declared dependencies. This will result in a compilation error. If you are using the standard firebase_functions package, you should likely use functions.http.onRequest to export your function.

publish_to: none

environment:
sdk: ^3.9.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The Dart SDK version constraint ^3.9.0 is invalid as this version has not been released yet. This will prevent the project from building or fetching dependencies. Consider using a current stable version like ^3.5.0.

  sdk: ^3.5.0

await ref.set(defaultContact.toJson());
return defaultContact;
}
return Contact.fromJson(snapshot.data()!);
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

Using the bang operator ! on snapshot.data() is discouraged. Even though snapshot.exists is checked, it is safer to handle the data nullability explicitly to prevent potential runtime crashes if the document exists but contains no fields.

  final data = snapshot.data();
  if (data == null) throw StateError('Document exists but has no data');
  return Contact.fromJson(data);

head.append(html.Element.tag('meta')..attributes['name'] = 'viewport'..attributes['content'] = 'width=device-width, initial-scale=1');
head.append(html.Element.tag('title')..text = titleText);
head.append(html.Element.tag('link')..attributes['rel'] = 'stylesheet'..attributes['href'] = 'https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css');
head.append(html.Element.tag('script')..attributes['src'] = 'https://cdn.jsdelivr.net/npm/htmx.org@4.0.0-beta3'..attributes['crossorigin'] = 'anonymous');
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 HTMX version 4.0.0-beta3 is incorrect. The current major version of HTMX is 2.x. Using a non-existent version will cause the script to fail to load from the CDN.

Suggested change
head.append(html.Element.tag('script')..attributes['src'] = 'https://cdn.jsdelivr.net/npm/htmx.org@4.0.0-beta3'..attributes['crossorigin'] = 'anonymous');
head.append(html.Element.tag('script')..attributes['src'] = 'https://cdn.jsdelivr.net/npm/htmx.org@2.0.3'..attributes['crossorigin'] = 'anonymous');

firebase.https.onRequest(
name: 'contact',
(request) async {
final docRef = firestore.collection('contacts').doc('1');
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 document ID is hardcoded to '1'. This limits the application to managing only a single contact record. Consider making this dynamic by extracting an ID from the request path or query parameters.

Comment on lines +172 to +174
contact.firstName = formData['firstName'] ?? contact.firstName;
contact.lastName = formData['lastName'] ?? contact.lastName;
contact.email = formData['email'] ?? contact.email;
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

Form data is assigned directly to the Contact object without validation. This could allow empty strings or malformed email addresses to be persisted in Firestore. It is recommended to validate required fields and formats before saving.

@wiz-9635d3485b
Copy link
Copy Markdown

wiz-9635d3485b Bot commented May 15, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities 3 High 4 Medium 1 Low
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total 3 High 4 Medium 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

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.

1 participant