Skip to content

Wrong asset id #97

@tima1906

Description

@tima1906

Initial Checks

  • I have searched the existing issues for a duplicate and I'm sure this is something new
  • I am confident that the issue in the project code

Description

I use the aiosteampy to keep statistics and look for matches between purchases and sales by float and pattern.
But I noticed that some links are broken and cannot be processed by CSFloat Api.
During my search, I found that the problem arises due to insufficient uniqueness of the parameters.
Functiion create_ident_code(mixed_data["instanceid"], mixed_data["classid"], app_id) generate code , but if (as I understand it) the same seller sells the 2 similar items ( M4 Solitude in my case), at the moment of generation MarketHistoryListingItem in _parse_assets_for_history_listings the second skin will have the assetid of the first skin. Perhaps my guess is wrong and the bug is caused by something else, but the fix helped generate it.
I just added assetid to create_ident_code in aiosteampy/mixins/market.py/:

    def _parse_item_descrs_from_my_listings_or_market_history(
        cls,
        data: dict[str, dict | list[dict]],
        item_descrs_map: T_SHARED_DESCRIPTIONS,
    ):
        # assets field, has descriptions for listings, so we can not parse descrs from listings
        for app_id, app_data in (data["assets"] or {}).items():  # thanks Steam for an empty list instead of a dict
            for context_id, context_data in app_data.items():
                for asset_id, mixed_data in context_data.items():
                    key = create_ident_code(mixed_data["instanceid"], mixed_data["classid"], asset_id, app_id) <--- added asset_id
                    if key not in item_descrs_map:
                        item_descrs_map[key] = cls._create_item_descr(mixed_data)

     

and in function _parse_assets_for_history_listings (same file):

description=item_descrs_map[
                    create_ident_code(
                        a_data["instanceid"],
                        a_data["classid"],
                        a_data["id"], <--- added param asset_id
                        app_id,
                    )

it would really be good to set create ident code with 4 params to make code more unique in all other places where this function is used
Example of bugged link steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M649201682349301907A45781488869D5246137917394352524
Correct link steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M652579382071856318A45781488869D5246137917394352524

Steps To Reproduce

Run events, total_count = await self.client.get_my_market_history(start=start, count=count)
Link creating link = description.actions[0].link.replace('%assetid%', str(asset.asset_id))

Environment

Winodws 11 
Python 3.13
aiosteampy 0.7.15

Additional Information

No response

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions