Skip to content

fix: merge watch config contexts without duplicates and reject blank names - #618

Open
aryarathoree wants to merge 1 commit into
microcks:masterfrom
aryarathoree:fix/watch-config-upsert-context-merge
Open

aryarathoree wants to merge 1 commit into
microcks:masterfrom
aryarathoree:fix/watch-config-upsert-context-merge

Conversation

@aryarathoree

Copy link
Copy Markdown
Contributor

Fixes #610

Summary

This PR addresses the watch configuration context-handling bugs in WatchConfig.UpsertEntry:

  1. Context Deduplication & Preservation: Merges incoming contexts with existing contexts without duplicates when re-upserting a watched file, preventing existing contexts from being deleted when updating a file from one context.
  2. Context Validation: Validates that entry.Context is non-empty and contains no blank/whitespace-only context names, returning descriptive errors to callers.
  3. Caller Handling: Propagates errors from UpsertEntry in cmd/import.go.
  4. Regression Tests: Adds test coverage in pkg/config/localconfig_test.go and pkg/config/config_test.go covering empty contexts, blank context names, context merging on re-upsert, and deduplication.

Co-authored-by: https://github.com/aniket866

@dipak0000812 dipak0000812 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @aryarathoree for addressing the context-loss issue, and thanks @aniket866 for collaborating.

I traced the policy-guards failure to the ignored writes in cmd/login_test.go. These were already fixed on upstream master in [197c2da](197c2da).

This PR branch is based on an earlier commit. Rebasing against the latest upstream/master should bring in that fix. You can then rerun the workflow to verify the result.

Merge contexts without duplicates in WatchConfig.UpsertEntry to prevent existing contexts from being deleted when re-upserting a watched file. Validate that context lists are non-empty and reject blank context names, propagating errors to callers.

Fixes microcks#610

Co-authored-by: aniket866 <iamaniketkumarmaner@gmail.com>
Signed-off-by: Arya Rathore <aryarathoree@gmail.com>
@aryarathoree
aryarathoree force-pushed the fix/watch-config-upsert-context-merge branch from 5b0adb4 to c31bbc7 Compare November 17, 2026 19:17
@aryarathoree

Copy link
Copy Markdown
Contributor Author

@dipak0000812 I've rebased the branch on latest master and signed off the commit. All CI checks (including policy-guards) are now green.

This branch was successfully deployed

1 active deployment
Build — c31bbc73 Deployed Nov 17, 2026 by aryarathoree via build-verify-package #892
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.

WatchConfig.UpsertEntry silently deletes existing contexts when re-upserting a watched file

2 participants