Skip to content

[BUG] Refactor results iteration to ensure exception safety in search_duckduckgo #3341

@coolbeevip

Description

@coolbeevip

Required prerequisites

What version of camel are you using?

0.2.79a0

System information

import sys, camel
print(sys.version, sys.platform)
print(camel.version)
print(sys.version, sys.platform)
3.11.8 (main, Jan 14 2025, 13:47:38) [Clang 15.0.0 (clang-1500.3.9.4)] darwin
print(camel.version)
0.2.79a0

Problem description

The iteration over results in the search_duckduckgo method is currently outside the try block. This could lead to unhandled exceptions if results is not properly initialized due to an earlier RequestException.

Reproducible example code

  1. Trigger a RequestException during the DuckDuckGo API call.
  2. Observe that results may not be defined, leading to a runtime error during iteration.

Traceback

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions