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: Avoid key-error when inserting asset chunks #550

Merged
merged 6 commits into from
Mar 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
if no key exists in map then skip
  • Loading branch information
ajay-sentry committed Feb 28, 2025
commit f8bb75d156d6b59bd1978538cde7597301401da6
8 changes: 6 additions & 2 deletions shared/bundle_analysis/parsers/v3.py
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ def parse(self, path: str) -> Tuple[int, str]:
assert self.session.bundle is not None
return self.session.id, self.session.bundle.name
except Exception as e:
# Inject the plugin name to the Exception object so we have visibilitity on which plugin
# Inject the plugin name to the Exception object so we have visibility on which plugin
# is causing the trouble.
e.bundle_analysis_plugin_name = self.info.get("plugin_name", "unknown")
raise e
@@ -408,10 +408,14 @@ def _create_associations(self):
for chunk in chunks:
chunk_id = chunk.id
asset_names = self.chunk_asset_names_index[chunk.unique_external_id]

# Only add assets which we have references for in the asset_name_to_id map
# This is to avoid inserting assets for non-JS files
inserts.extend(
[
dict(asset_id=asset_name_to_id[asset_name], chunk_id=chunk_id)
dict(asset_id=asset_name_to_id.get(asset_name), chunk_id=chunk_id)
for asset_name in asset_names
if asset_name_to_id.get(asset_name) is not None
]
)
if inserts: