fix: added branch set via the stack config#191
Merged
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
netrajpatel
approved these changes
Jul 16, 2026
c2dbaec
into
feat/taxonomy-publishing-localisation-2
9 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs in the taxonomy localisation implementation introduced in
feat: add localized taxonomy and term delivery (CDA) support:?? "main"breaks non-branched stacks — every request injectedbranch=mainwhenConfig.Branchwas null, causing422 Branch not foundon any stack without branching configured.TaxonomyException.CreateForProcessingError(ex)wrapped the raw exception without reading the API response body, leavingErrorCode,StatusCode, andErrorsalways at their zero/null defaults.Files Changed
Contentstack.Core/Models/Taxonomy.cs?? "main"branch fallback; wireGetContentstackError()into catch blockContentstack.Core/Models/Term.cs?? "main"branch fallback inExecuteRequest; wireGetContentstackError()in all four catch blocks (Fetch,Locales,Ancestors,Descendants)Contentstack.Core/Models/TermQuery.cs?? "main"branch fallback; wireGetContentstackError()into catch block; swapnew List<T>()empty fallback forEnumerable.Empty<T>()Contentstack.Core.Tests/Integration/Taxonomy/TaxonomyLocalisationTest.csBug 1 — Branch fallback
?? "main"Before
After
Why it broke
When a stack is created without branching configured,
Config.Branchisnull.HttpRequestHandler.ProcessRequestomits thebranchheader when passednull— correct behaviour. The?? "main"fallback bypassed that and sentbranch=mainon every request. Any stack that does not have a branch named"main"got a422 Branch not foundback from the CDA.AssetandEntrypassConfig.Branchdirectly with no fallback. This change aligns taxonomy with that pattern.Bug 2 — Structured error propagation
Before
CreateForProcessingErrordoes this:It formats the exception message string and wraps it. It never reads the HTTP response body. So on a
401or422, callers got:After
GetContentstackError(ex)was already present onTaxonomy— identical to the implementation onAssetandEntry. It opens theWebExceptionresponse stream, reads the JSON body, and extractserror_code,error_message, anderrors. Callers now get:This allows proper error handling at the call site:
Minor —
TermQuery.Find<T>()empty fallbackChanged
new List<T>()toEnumerable.Empty<T>()for the zero-terms case. Avoids allocating an empty list on every call that returns no terms.Out of scope
Taxonomy.csstill contains dead code carried over from the initial implementation:_ObjectAttributes,_Headers,_StackHeaders,UrlQueries, andGetHeader()are all declared but never used in any active code path.GetContentstackError()itself is now used but was previously dead. Cleaning up the remaining dead fields belongs in a separate PR to keep the diff reviewable.Test results
Integration tests (
TaxonomyLocalisationTest) cover all eight CDA endpoints against the real API and pass unchanged.