Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve error handling at startup #5994

Conversation

ogabrielluiz
Copy link
Contributor

Enhance the robustness of API requests by adding comprehensive error handling and logging mechanisms. This change aims to provide clearer feedback during failures and improve overall user experience.

Catch and handle potential network connection errors when attempting to build the version notice, preventing potential startup failures due to version check issues
Enhance version notice function by:
- Adding comprehensive docstring with description, args, returns, and example
- Using contextlib.suppress to handle network errors
- Removing redundant try-except block in print_banner
- Simplifying version check logic
Change telemetry service error logging from `logger.exception()` to `logger.error()` to reduce verbosity and prevent unnecessary stack trace printing
Remove unused logger import and exception logging in version check function to simplify error handling and reduce unnecessary logging
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jan 29, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/backend/base/langflow/main.py:370

  • Ensure that package_name is found in notice before calling stylize_text to avoid unexpected behavior.
notice = stylize_text(notice, package_name, is_prerelease=is_pre_release)

src/backend/base/langflow/main.py:330

  • Update the example in the docstring to reflect that the function may return an empty string if no newer version is available.
>>> build_version_notice("1.0.0", "langflow")
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 29, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jan 29, 2025
@ogabrielluiz ogabrielluiz requested a review from Copilot January 29, 2025 12:41
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 29, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (4)

src/backend/base/langflow/utils/version.py:87

  • Removing logger.exception hides errors that occur during the fetching process, making it harder to diagnose issues. Consider keeping some form of logging to capture these errors.
return None

src/backend/base/langflow/services/telemetry/service.py:75

  • [nitpick] Changing from logger.exception to logger.error reduces the amount of information available for debugging. Confirm if this reduction in logging detail is intentional and won't impact debugging.
logger.error("HTTP error occurred")

src/backend/base/langflow/services/telemetry/service.py:77

  • [nitpick] Changing from logger.exception to logger.error reduces the amount of information available for debugging. Confirm if this reduction in logging detail is intentional and won't impact debugging.
logger.error("Request error occurred")

src/backend/base/langflow/services/telemetry/service.py:79

  • [nitpick] Changing from logger.exception to logger.error reduces the amount of information available for debugging. Confirm if this reduction in logging detail is intentional and won't impact debugging.
logger.error("Unexpected error occurred")
@Cristhianzl
Copy link
Member

I'll send you a suggestion on dm!

Copy link
Member

@Cristhianzl Cristhianzl left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 29, 2025
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit c7584d8 Jan 29, 2025
33 of 42 checks passed
@ogabrielluiz ogabrielluiz deleted the 5327-langflow-does-not-start-in-airgapped-environment-despite-setting-do_not_tracktrue branch January 29, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Langflow does not start in airgapped environment despite setting DO_NOT_TRACK=true
2 participants