feat: Added branch support in entry variants#207
Conversation
- **New** - **Branch override for Entry Variants**: `Entry.Variant(uid?, branchUid?)` accepts an optional `branchUid` so a single variant call (`Find`, `Create`, `Update`, `Fetch`, `Delete`) can target a branch other than the `Stack`'s configured one, by overriding the `branch` request header. Passing `null`/whitespace falls back to the Stack's own branch. - **Publish/Unpublish for Entry Variants**: `EntryVariant.Publish`/`PublishAsync` and `EntryVariant.Unpublish`/`UnpublishAsync`, matching the same `PublishUnpublishDetails` contract as `Entry.Publish`/`Unpublish`, and respecting the same branch override.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
There was a problem hiding this comment.
Pull request overview
Adds branch-targeting support and publish/unpublish capabilities to Entry Variants in the Contentstack Management .NET SDK, enabling variant operations to override the Stack’s configured branch via the branch request header.
Changes:
- Extended
Entry.Variant(uid?, branchUid?)andEntryVariantrequests to optionally override thebranchheader per call. - Added
EntryVariant.Publish/Unpublish(sync + async) using the existingPublishUnpublishDetailscontract. - Updated unit/integration tests and bumped package version + changelog for the release.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Directory.Build.props | Bumps SDK version to 1.1.0. |
| Contentstack.Management.Core/Models/EntryVariant.cs | Stores branch override and applies it to variant CRUD + adds publish/unpublish support. |
| Contentstack.Management.Core/Models/Entry.cs | Adds optional branchUid parameter to Variant(...). |
| Contentstack.Management.Core.Unit.Tests/Mokes/MockHttpHandler.cs | Captures last request headers for branch override assertions. |
| Contentstack.Management.Core.Unit.Tests/Models/EntryVariantTest.cs | Adds unit tests covering branch header override + publish/unpublish behavior. |
| Contentstack.Management.Core.Tests/IntegrationTest/Contentstack021_EntryVariantTest.cs | Adds branch override integration scenarios (branch creation, fetch, fallback, publish). |
| CHANGELOG.md | Documents new 1.1.0 features for entry variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
1 similar comment
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
| var httpRequest = executionContext.RequestContext.service.CreateHttpRequest( | ||
| null, | ||
| executionContext.RequestContext.config | ||
| ); | ||
| LastRequestUri = httpRequest.RequestUri; | ||
| LastRequestHeaders = executionContext.RequestContext.service.Headers; | ||
| } |
| var httpRequest = executionContext.RequestContext.service.CreateHttpRequest( | ||
| null, | ||
| executionContext.RequestContext.config | ||
| ); | ||
| LastRequestUri = httpRequest.RequestUri; | ||
| LastRequestHeaders = executionContext.RequestContext.service.Headers; | ||
| } |
| AssertLogger.IsTrue( | ||
| response.IsSuccessStatusCode || (int)response.StatusCode >= 400, | ||
| "Expected the SDK to return a well-formed HTTP response for the branch-scoped request", | ||
| "FetchVariantOnExplicitBranch"); |
| AssertLogger.IsTrue( | ||
| response.IsSuccessStatusCode || (int)response.StatusCode >= 400, | ||
| "Expected the SDK to return a well-formed HTTP response for the branch-scoped request", | ||
| "FetchVariantOnExplicitBranchAsync"); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
1 similar comment
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
…-override assertions
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
This reverts commit b23f36a.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
This reverts commit 6c4ffbd.
This reverts commit df8af7b.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
This reverts commit 44aeae2.
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
2 similar comments
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
…iability - Remove version duplication in AddVariantToDetails: auto-created PublishVariant now carries only the variant Uid, keeping entry version at the top-level only - Snapshot service.Headers into a new Dictionary in MockHttpHandler (both sync and async) to prevent later mutations from corrupting header assertions - Tighten always-true assertions in Test084/Test085 integration tests to assert response.IsSuccessStatusCode instead of the tautological success-or-error check - Update Should_Publish_EntryVariant unit test to match new variant behavior Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
- Add WaitBeforeRetryAsync to RetryPolicy base class so the async retry loop can await the delay instead of blocking a thread pool thread - Override WaitBeforeRetryAsync in DefaultRetryPolicy with a proper async implementation; sync WaitBeforeRetry now delegates to it via GetResult - RetryHandler.InvokeAsync now awaits WaitBeforeRetryAsync instead of calling the blocking WaitBeforeRetry - Replace DateTime.UtcNow with Stopwatch in InvokeAsync_Applies_NetworkRetryDelay and InvokeAsync_Applies_HttpRetryDelay: Stopwatch uses QueryPerformanceCounter and is not subject to the 15.6ms Windows system clock resolution that caused the 50ms delay assertion to sporadically fail in CI Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Replace DateTime.UtcNow with Stopwatch in all three WaitBeforeRetry timing tests. DateTime.UtcNow has ~15ms resolution on Windows CI runners, making tight delay assertions (>= 200ms, <= 300ms) intermittently fail. Stopwatch uses QueryPerformanceCounter and is not subject to clock tick granularity. Also remove upper-bound assertions — the important correctness check is that the delay was applied (lower bound), not how long the OS scheduler took. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Entry.Variant(uid?, branchUid?)accepts an optionalbranchUidso a single variant call (Find,Create,Update,Fetch,Delete) can target a branch other than theStack's configured one, by overriding thebranchrequest header. Passingnull/whitespace falls back to the Stack's own branch.EntryVariant.Publish/PublishAsyncandEntryVariant.Unpublish/UnpublishAsync, matching the samePublishUnpublishDetailscontract asEntry.Publish/Unpublish, and respecting the same branch override.