Skip to content

fix(android): Fall back to compiled_item ref ID for AAB resource resolution#572

Merged
runningcode merged 2 commits intomainfrom
no/fix-proto-xml-resource-fallback
Mar 3, 2026
Merged

fix(android): Fall back to compiled_item ref ID for AAB resource resolution#572
runningcode merged 2 commits intomainfrom
no/fix-proto-xml-resource-fallback

Conversation

@runningcode
Copy link
Contributor

@runningcode runningcode commented Mar 2, 2026

Summary

  • When an AAB manifest attribute has a value string like @string/app_name_bootstrap that doesn't match any entry in the protobuf resource table, the code now falls back to resolving via the compiled_item.ref.id instead of returning None.
  • This fixes apps where the manifest label references a resource name that doesn't exist in resources.pb, but the numeric resource ID in compiled_item.ref.id resolves correctly.

Root Cause

In _get_optional_attr_value(), when attribute.value starts with @, it calls get_value_by_key() for a name-based lookup and directly returns the result — even if None. It never tries the compiled_item.ref.id path which resolves by numeric resource ID.

Production logs for a failing artifact:

optionalAttrValueWithFallback: label, 1010001
could not find attribute matching filter
could not find attribute by name, trying to find by resourceId
No entry found with the name @string/app_name_bootstrap.

The resource ID-based lookup would have succeeded, but was never attempted.

Fixes EME-900

…lution

When an AAB manifest attribute has a string value like
"@string/app_name_bootstrap" that doesn't match any entry in the
protobuf resource table, the code now falls back to resolving via the
compiled_item's reference ID instead of returning None.

This fixes apps (e.g. ING Banking) where the manifest label references
a resource name that doesn't exist in resources.pb, but the numeric
resource ID in compiled_item.ref.id resolves correctly.
@linear
Copy link

linear bot commented Mar 2, 2026

@runningcode runningcode marked this pull request as ready for review March 2, 2026 17:09

# Key-based lookup failed, fall back to compiled_item ref ID
logger.debug(f"key-based lookup failed for {value}, trying compiled_item ref")
compiled_item = getattr(attribute, "compiled_item", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the getattr is right here. The generated interface (Resources_pb2.pyi) implies it will always exist as a field on the object.

I think the right thing is either:

compiled_item = attribute.compiled_item if attribute.HasField("compiled_item") else None

If we need to handle this being unset, or:

compiled_item = attribute.compiled_item

if not.

Copy link
Contributor

@chromy chromy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % one comment

Use the idiomatic protobuf HasField() instead of getattr() since
compiled_item is a defined field on the proto message and always
exists as an attribute.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@runningcode runningcode merged commit d30e2b0 into main Mar 3, 2026
26 of 27 checks passed
@runningcode runningcode deleted the no/fix-proto-xml-resource-fallback branch March 3, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants