SK-2679: Add typed context accessors for Conditional Data Access (Map support)#302
SK-2679: Add typed context accessors for Conditional Data Access (Map support)#302samsternberg wants to merge 4 commits intomainfrom
Conversation
- Add typed getContext() (String), getContextAsObject(), getContextAsMap() to Credentials; @SuppressWarnings scoped to Credentials where the invariant is guaranteed by the typed setContext overloads - Remove unchecked cast and @SuppressWarnings from Utils.generateBearerToken by using the new typed accessors - Assert getContextAsObject/getContextAsMap behaviour in CredentialsTests Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
✅ Gitleaks Findings: No secrets detected. Safe to proceed! |
|
Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging. |
- Extract validateCtxMapKeys() from validateCredentials into a public helper on Validations so builders can call it directly - Add throws SkyflowException + validateCtxMapKeys() to setCtx(Map) in BearerToken and SignedDataTokens builders for early validation - Add nested map, credentials-string, and invalid-key tests for both BearerToken and SignedDataTokens builders Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
✅ Gitleaks Findings: No secrets detected. Safe to proceed! |
|
Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging. |
…check getContext() now returns String (null for Map), so validateCredentials was silently skipping Map context validation. Switch to getContextAsObject() to restore instanceof Map branching. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
✅ Gitleaks Findings: No secrets detected. Safe to proceed! |
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging. |
|
✅ Gitleaks Findings: No secrets detected. Safe to proceed! |
|
Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging. |
|
While rebasing this PR we discovered that SK-2777 (PR #301, "Update Fern client re-initialisation") already shipped the core Map context feature on main — even though SK-2777's ticket scope is purely about Fern client initialisation performance. Specifically, #301 landed:
What this PR (SK-2679) adds on top of that:
Action needed: Someone should confirm whether SK-2777 intentionally included the Map context changes or if they were accidentally bundled in. If intentional, SK-2679 can be scoped down to just the type-safety improvements in this PR. If accidental, the team should be aware that the feature is already live on |
Summary
getContext()(String),getContextAsObject(), andgetContextAsMap()typed accessors toCredentials, replacing the untypedObject getContext()from SK-2777@SuppressWarnings("unchecked")fromUtils.generateBearerTokenby using the new typed accessors — cast safety is now enforced inCredentialsnext to the typedsetContextoverloadsCredentialsTeststo assertgetContextAsObject()/getContextAsMap()behaviourReplaces #293 (closed due to conflicts with SK-2777).
Test plan
mvn testpasses locallytestValidMapContextInCredentials,testEmptyMapContextInCredentials,testInvalidMapKeyInContextCredentials,testMapContextWithNestedObjects,testMapContextWithMixedValueTypes) still passtestValidMapContextInCredentialsverify typed accessor returns🤖 Generated with Claude Code