adk-samples icon indicating copy to clipboard operation
adk-samples copied to clipboard

Duplicate key name

Open Cascoopman opened this issue 1 year ago • 1 comments

Location: https://github.com/google/adk-samples/blob/main/agents/personalized-shopping/personalized_shopping/shared_libraries/web_agent_site/engine/goal.py#L134

There is a duplicate dictionary key "name" in the product_goals.append() call:

product_goals.append(
    {
        "asin": asin,
        "category": product["category"],
        "query": product["query"],
        "name": product["name"],  # First definition
        "product_category": product["product_category"],
        "instruction_text": f"{instruction_text}{option_text}{price_text}",
        "attributes": attributes,
        "price_upper": price_upper,
        "goal_options": goal_options,
        "name": product["Title"],  # Overwrites previous 'name'
    }
)

This results in the "name" field being silently overwritten with product["Title"], potentially replacing the actual product name.

✅ Fix

Rename one of the "name" keys or remove the duplicate to preserve the intended value.

Example fix:

"name": product["name"],
"title": product["Title"],  # Renamed to avoid conflict

Cascoopman avatar Apr 11 '25 07:04 Cascoopman

closing the issue as the PR is merged

turanbulmus avatar May 14 '25 08:05 turanbulmus