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

[Bug]: Line 38 in teams.utils.get_used_citations will raise "AttributeError: 'dict' object has no attribute 'position'" #2308

Open
frankqianms opened this issue Feb 13, 2025 · 10 comments
Assignees
Labels
bug Something isn't working Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label

Comments

@frankqianms
Copy link

frankqianms commented Feb 13, 2025

Language

Python

Version

latest

Description

Image
The dict object of citation will raise no attribute position if use citation.position.
if str(citation.position) == match: ^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'position'

Reproduction Steps

1.
...
@frankqianms frankqianms added the bug Something isn't working label Feb 13, 2025
@frankqianms frankqianms changed the title [Bug]: Line 38 in teams.utils.get_used_citations will raise "Dict citation does not have property position" error [Bug]: Line 38 in teams.utils.get_used_citations will raise "AttributeError: 'dict' object has no attribute 'position'" Feb 13, 2025
@Nivedipa-MSFT
Copy link

Nivedipa-MSFT commented Feb 13, 2025

@frankqianms - Thank you for reaching out! To assist you better, could you please provide a detailed description of the steps you took to encounter the issue?

@frankqianms
Copy link
Author

@frankqianms - Thank you for reaching out! To assist you better, could you please provide a detailed description of the steps you took to encounter the issue?

I wrote my own SAY_COMMAND in my bot: https://github.com/[frankqianms/custom-datasource-py](https://github.com/frankqianms/custom-datasource-py). If I import get_used_citations from teams.utils.citations, the bug occurs. So I rewrote the method.

@lilyydu lilyydu added the Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label label Feb 14, 2025
@Nivedipa-MSFT
Copy link

@frankqianms - We are not quite clear on your issue. Are you developing any Teams app? If yes, could you please share the repro steps to try at our end. Your shared link is not accessible at our end.

@lilyydu
Copy link
Collaborator

lilyydu commented Feb 20, 2025

Hey @frankqianms,

This seems like a key-access error with the Dict. I believe using brackets should do the trick- noticed you implemented this fix here
https://github.com/frankqianms/custom-datasource-py/blob/main/src/custom_say_command.py#L27

Did this resolve for you?

@frankqianms
Copy link
Author

@lilyydu - Yes, it works.

@lilyydu
Copy link
Collaborator

lilyydu commented Feb 21, 2025

@frankqianms Thanks for checking. Would you be open to filing a quick PR fix for this when you get the chance?

@frankqianms
Copy link
Author

@lilyydu I can take a try. And besides the get_used_citations codes, any related test cases need to be modified?

@lilyydu
Copy link
Collaborator

lilyydu commented Feb 24, 2025

@frankqianms That would be greatly appreciated, thank you! There might be some tests in test_streaming_response.py - but should be simple + quick

@frankqianms
Copy link
Author

@lilyydu Created a pr: #2327

@frankqianms
Copy link
Author

@lilyydu After some checks, I closed the pr: #2327. The attributeError occurs when I manually format the citation as a dict type. I belive the planner will return a correct ClientCitation type so that there is no need to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Change/fix applies to Python. If all three, use the 'JS & dotnet & Python' label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants