Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Description

The SignTool throws KeyNotFoundException when attempting to access dictionary entries for containers with DoNotUnpack=true. When this flag is set, containers skip unpacking and aren't added to _zipDataMap, but subsequent code directly accesses the dictionary without checking for existence.

Changes

Modified Configuration.cs to use conditional dictionary access:

  • Line 282-296: Changed _zipDataMap[key] to TryGetValue pattern. Handles both DoNotUnpack skips and failed unpacking attempts. Logs error if container was expected but not unpacked.

  • Line 364-369: Added TryGetValue for parent container collision ID lookups. Falls back to empty string and logs detailed error with parent hash when lookup fails.

To double check:

Original prompt

Since the merge of PR #16371, the sign tool throws a KeyNotFoundException when the DoNotUnpack flag is set on a container (e.g., .zip or .nupkg). The error occurs when the signing logic attempts to access dictionary entries for files inside containers that are no longer unpacked for signing. This update modifies Configuration.cs so that when DoNotUnpack is set, inner files are not tracked or looked up in the relevant dictionary, preventing KeyNotFoundException. It uses conditional TryGetValue access to the dictionary and skips tracking or lookup for children of DoNotUnpack containers. The error message is also improved for other missing keys.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix KeyNotFoundException when DoNotUnpack flag is set Fix KeyNotFoundException when DoNotUnpack flag is set on containers Jan 10, 2026
Copilot AI requested a review from ViktorHofer January 10, 2026 18:51
}
else
{
_log.LogError($"Container '{fileSignInfo.FullPath}' was not unpacked. Cannot determine signable parts. This may indicate an internal error in the signing logic.");
Copy link
Member

Choose a reason for hiding this comment

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

I thought you were saying that key not found was expected in some cases, yet this will error in that case.

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.

3 participants