Skip to content

Conversation

@a-maurice
Copy link
Contributor

Description

Provide details of the change, and generalize the change in the PR title above.

Fix error in build report script when the FTL devices can't be found


Testing

Describe how you've tested these changes. Link any manually triggered Integration tests or CPP binary SDK Packaging Github Action workflows, if applicable.

https://github.com/firebase/firebase-cpp-sdk/actions/runs/20252064775


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @a-maurice, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the build report generation script. Previously, the script would encounter an error if it failed to retrieve information for certain FTL devices. The implemented change adds a check to ensure that device data is valid before processing, thereby enhancing the script's stability and preventing unexpected failures during report generation.

Highlights

  • Bug Fix: Addresses an error in the build report script that occurred when FTL (Firebase Test Lab) devices could not be found.
  • Improved Robustness: The script now gracefully handles cases where device information is unavailable, preventing crashes and ensuring the reporting process completes successfully.
  • Code Change: Introduced a null check for the return value of the get_test_device() function before attempting to access its properties, specifically the 'type' attribute.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@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 fixes a crash in the build report script that occurs when FTL devices are not found. The fix correctly adds a null check before accessing attributes of a device. My review includes suggestions to refactor the changed sections to improve efficiency and readability by using a single loop to process devices, avoiding repeated function calls and multiple iterations over the same data. This also makes the code more robust by using explicit equality checks instead of in for string comparison.

Comment on lines +391 to +392
ftl_devices = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "ftl", config_value))
simulators = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "virtual", config_value))
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the added check for get_test_device(device) correctly prevents a crash, this implementation can be improved for readability and efficiency.

  1. Repeated function calls: get_test_device(device) is called twice in the lambda for each device, and config_value is iterated over twice (once for ftl_devices, once for simulators).
  2. Confusing string check: Using in "ftl" or in "virtual" is confusing and less precise than ==. It works here because the only possible values are "ftl" and "virtual", but it's brittle.

I suggest refactoring this to a single loop that categorizes devices. This is more efficient and readable.

Suggested change
ftl_devices = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "ftl", config_value))
simulators = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "virtual", config_value))
ftl_devices = set()
simulators = set()
for device in config_value:
test_device = get_test_device(device)
if not test_device:
continue
device_type = test_device.get("type")
if device_type == "ftl":
ftl_devices.add(device)
elif device_type == "virtual":
simulators.add(device)

Comment on lines +400 to +401
ftl_devices = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "ftl", config_value))
emulators = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "virtual", config_value))
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the ios_device case, this logic can be refactored to be more efficient and readable by using a single loop. This avoids iterating over config_value multiple times and calling get_test_device repeatedly inside the lambdas. This change also replaces the confusing in "string" check with a clearer == comparison.

Suggested change
ftl_devices = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "ftl", config_value))
emulators = set(filter(lambda device: get_test_device(device) and get_test_device(device).get("type") in "virtual", config_value))
ftl_devices = set()
emulators = set()
for device in config_value:
test_device = get_test_device(device)
if not test_device:
continue
device_type = test_device.get("type")
if device_type == "ftl":
ftl_devices.add(device)
elif device_type == "virtual":
emulators.add(device)

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