feat: added smithy for workspace lock#1006
Conversation
WalkthroughIntroduces workspace lock modeling and a 409 WorkspaceLockConflict error in Smithy, propagates to all SDKs (Rust, Java, Python, TypeScript, Haskell), updates serializers/deserializers and error registries, exposes optional workspace_lock in responses, and documents via OpenAPI and MDX/StatusCodes. ChangesWorkspace lock + conflict error surfaced across stack
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Pull request overview
This PR extends the Smithy API model to represent a workspace write-lock (workspace_lock) and introduces a modeled 409 error (WorkspaceLockConflict) for write operations blocked by an active lock, then propagates the updated model through generated OpenAPI/docs and multi-language SDKs.
Changes:
- Added
WorkspaceLockshape andworkspace_lockproperty on theWorkspaceresource / responses. - Added
WorkspaceLockConflict(409) error and aWorkspaceWriteOperationmixin, applying it to default-config write operations. - Regenerated OpenAPI/docs and SDKs (Rust, Python, JavaScript, Java, Haskell) to include the new shapes and error types.
Reviewed changes
Copilot reviewed 91 out of 91 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| smithy/patches/java.patch | Updates Java-generation patch to include workspace_lock and adds RotateWorkspaceEncryptionKey to workspace operations. |
| smithy/models/workspace.smithy | Adds workspace_lock property and defines the WorkspaceLock structure; exposes workspace_lock on WorkspaceResponse. |
| smithy/models/main.smithy | Adds WorkspaceLockConflict (409) error and WorkspaceWriteOperation mixin. |
| smithy/models/default-config.smithy | Applies WorkspaceWriteOperation (and thus 409) to Create/Update/Delete default-config operations. |
| docs/docs/api/update-workspace.StatusCodes.json | Updates UpdateWorkspace response schema to include workspace_lock. |
| docs/docs/api/update-workspace.api.mdx | Regenerated UpdateWorkspace API doc payload. |
| docs/docs/api/update-default-config.StatusCodes.json | Adds documented 409 (WorkspaceLockConflict) to UpdateDefaultConfig. |
| docs/docs/api/update-default-config.api.mdx | Regenerated UpdateDefaultConfig API doc payload. |
| docs/docs/api/Superposition.openapi.json | Adds WorkspaceLock, WorkspaceLockConflictResponseContent, and 409 responses for default-config write operations; adds workspace_lock in workspace schemas. |
| docs/docs/api/migrate-workspace-schema.StatusCodes.json | Updates MigrateWorkspaceSchema response schema to include workspace_lock. |
| docs/docs/api/migrate-workspace-schema.api.mdx | Regenerated MigrateWorkspaceSchema API doc payload. |
| docs/docs/api/list-workspace.StatusCodes.json | Updates ListWorkspace response schema to include workspace_lock. |
| docs/docs/api/list-workspace.api.mdx | Regenerated ListWorkspace API doc payload. |
| docs/docs/api/get-workspace.StatusCodes.json | Updates GetWorkspace response schema to include workspace_lock. |
| docs/docs/api/get-workspace.api.mdx | Regenerated GetWorkspace API doc payload. |
| docs/docs/api/delete-default-config.StatusCodes.json | Adds documented 409 (WorkspaceLockConflict) to DeleteDefaultConfig. |
| docs/docs/api/delete-default-config.api.mdx | Regenerated DeleteDefaultConfig API doc payload. |
| docs/docs/api/create-workspace.StatusCodes.json | Updates CreateWorkspace response schema to include workspace_lock. |
| docs/docs/api/create-workspace.api.mdx | Regenerated CreateWorkspace API doc payload. |
| docs/docs/api/create-default-config.StatusCodes.json | Adds documented 409 (WorkspaceLockConflict) to CreateDefaultConfig. |
| docs/docs/api/create-default-config.api.mdx | Regenerated CreateDefaultConfig API doc payload. |
| crates/superposition_sdk/src/types/error/builders.rs | Re-exports Rust builder for WorkspaceLockConflict. |
| crates/superposition_sdk/src/types/error/_workspace_lock_conflict.rs | Adds Rust modeled error type WorkspaceLockConflict. |
| crates/superposition_sdk/src/types/error.rs | Registers Rust error module/type for WorkspaceLockConflict. |
| crates/superposition_sdk/src/types/builders.rs | Re-exports Rust builder for WorkspaceLock. |
| crates/superposition_sdk/src/types/_workspace_response.rs | Adds optional workspace_lock to Rust WorkspaceResponse. |
| crates/superposition_sdk/src/types/_workspace_lock.rs | Adds Rust WorkspaceLock type + builder. |
| crates/superposition_sdk/src/types.rs | Exports WorkspaceLock from Rust types module. |
| crates/superposition_sdk/src/serde_util.rs | Adds Rust error-correction helpers for new lock/error shapes. |
| crates/superposition_sdk/src/protocol_serde/shape_workspace_response.rs | Deserializes workspace_lock into Rust WorkspaceResponse. |
| crates/superposition_sdk/src/protocol_serde/shape_workspace_lock.rs | Adds Rust JSON deserializer for WorkspaceLock. |
| crates/superposition_sdk/src/protocol_serde/shape_workspace_lock_conflict.rs | Adds Rust JSON error-body deserializer for WorkspaceLockConflict. |
| crates/superposition_sdk/src/protocol_serde/shape_update_workspace.rs | Deserializes workspace_lock into Rust UpdateWorkspace output. |
| crates/superposition_sdk/src/protocol_serde/shape_update_default_config.rs | Adds Rust HTTP error mapping for WorkspaceLockConflict on UpdateDefaultConfig. |
| crates/superposition_sdk/src/protocol_serde/shape_migrate_workspace_schema.rs | Deserializes workspace_lock into Rust MigrateWorkspaceSchema output. |
| crates/superposition_sdk/src/protocol_serde/shape_get_workspace.rs | Deserializes workspace_lock into Rust GetWorkspace output. |
| crates/superposition_sdk/src/protocol_serde/shape_delete_default_config.rs | Adds Rust HTTP error mapping for WorkspaceLockConflict on DeleteDefaultConfig. |
| crates/superposition_sdk/src/protocol_serde/shape_create_workspace.rs | Deserializes workspace_lock into Rust CreateWorkspace output. |
| crates/superposition_sdk/src/protocol_serde/shape_create_default_config.rs | Adds Rust HTTP error mapping for WorkspaceLockConflict on CreateDefaultConfig. |
| crates/superposition_sdk/src/protocol_serde.rs | Registers new Rust protocol serde modules for lock/conflict. |
| crates/superposition_sdk/src/operation/update_workspace/_update_workspace_output.rs | Adds optional workspace_lock to Rust UpdateWorkspace output. |
| crates/superposition_sdk/src/operation/update_default_config.rs | Adds WorkspaceLockConflict variant to Rust UpdateDefaultConfigError. |
| crates/superposition_sdk/src/operation/migrate_workspace_schema/_migrate_workspace_schema_output.rs | Adds optional workspace_lock to Rust MigrateWorkspaceSchema output. |
| crates/superposition_sdk/src/operation/get_workspace/_get_workspace_output.rs | Adds optional workspace_lock to Rust GetWorkspace output. |
| crates/superposition_sdk/src/operation/delete_default_config.rs | Adds WorkspaceLockConflict variant to Rust DeleteDefaultConfigError. |
| crates/superposition_sdk/src/operation/create_workspace/_create_workspace_output.rs | Adds optional workspace_lock to Rust CreateWorkspace output. |
| crates/superposition_sdk/src/operation/create_default_config.rs | Adds WorkspaceLockConflict variant to Rust CreateDefaultConfigError. |
| crates/superposition_sdk/src/error_meta.rs | Promotes WorkspaceLockConflict into Rust top-level error enum conversions/metadata. |
| crates/superposition_sdk/src/client/update_workspace.rs | Documents workspace_lock field in UpdateWorkspace client docs. |
| crates/superposition_sdk/src/client/migrate_workspace_schema.rs | Documents workspace_lock field in MigrateWorkspaceSchema client docs. |
| crates/superposition_sdk/src/client/get_workspace.rs | Documents workspace_lock field in GetWorkspace client docs. |
| crates/superposition_sdk/src/client/create_workspace.rs | Documents workspace_lock field in CreateWorkspace client docs. |
| clients/python/sdk/superposition_sdk/models.py | Adds Python WorkspaceLock and WorkspaceLockConflict; wires into relevant operations and outputs. |
| clients/python/sdk/superposition_sdk/deserialize.py | Adds Python deserialization for WorkspaceLockConflict error. |
| clients/python/sdk/superposition_sdk/_private/schemas.py | Adds Python schema definitions for WorkspaceLock + WorkspaceLockConflict and references from workspace outputs. |
| clients/javascript/sdk/src/protocols/Aws_restJson1.ts | Adds JS protocol deserialization for WorkspaceLock and WorkspaceLockConflict. |
| clients/javascript/sdk/src/models/models_0.ts | Adds JS model types for WorkspaceLock and WorkspaceLockConflict; adds workspace_lock to WorkspaceResponse. |
| clients/javascript/sdk/src/commands/UpdateWorkspaceCommand.ts | Updates command output docs to include workspace_lock. |
| clients/javascript/sdk/src/commands/UpdateDefaultConfigCommand.ts | Documents WorkspaceLockConflict throw type. |
| clients/javascript/sdk/src/commands/MigrateWorkspaceSchemaCommand.ts | Updates command output docs to include workspace_lock. |
| clients/javascript/sdk/src/commands/ListWorkspaceCommand.ts | Updates command output docs to include workspace_lock. |
| clients/javascript/sdk/src/commands/GetWorkspaceCommand.ts | Updates command output docs to include workspace_lock. |
| clients/javascript/sdk/src/commands/DeleteDefaultConfigCommand.ts | Documents WorkspaceLockConflict throw type. |
| clients/javascript/sdk/src/commands/CreateWorkspaceCommand.ts | Updates command output docs to include workspace_lock. |
| clients/javascript/sdk/src/commands/CreateDefaultConfigCommand.ts | Documents WorkspaceLockConflict throw type. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceResponse.java | Adds workspace_lock to Java WorkspaceResponse. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLockConflict.java | Adds Java modeled exception WorkspaceLockConflict. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLock.java | Adds Java WorkspaceLock model. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/Workspace.java | Adds workspace_lock to Java Workspace resource properties. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/UpdateWorkspaceOutput.java | Adds workspace_lock to Java UpdateWorkspace output. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/UpdateDefaultConfig.java | Registers WorkspaceLockConflict in Java UpdateDefaultConfig type registry. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/MigrateWorkspaceSchemaOutput.java | Adds workspace_lock to Java MigrateWorkspaceSchema output. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/GetWorkspaceOutput.java | Adds workspace_lock to Java GetWorkspace output. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/DeleteDefaultConfig.java | Registers WorkspaceLockConflict in Java DeleteDefaultConfig type registry. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/CreateWorkspaceOutput.java | Adds workspace_lock to Java CreateWorkspace output. |
| clients/java/sdk/src/main/java/io/juspay/superposition/model/CreateDefaultConfig.java | Registers WorkspaceLockConflict in Java CreateDefaultConfig type registry. |
| clients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionClientImpl.java | Regenerated ordering in Java client type registry initialization. |
| clients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionClient.java | Adds WorkspaceLockConflict import/throws docs and regens auth scheme declaration order. |
| clients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionAsyncClientImpl.java | Regenerated ordering in Java async client type registry initialization. |
| clients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionAsyncClient.java | Adds WorkspaceLockConflict import/throws docs and regens auth scheme declaration order. |
| clients/haskell/sdk/SuperpositionSDK.cabal | Adds new Haskell modules to cabal export list. |
| clients/haskell/sdk/Io/Superposition/Model/WorkspaceResponse.hs | Adds optional workspace_lock to Haskell WorkspaceResponse. |
| clients/haskell/sdk/Io/Superposition/Model/WorkspaceLockConflict.hs | Adds Haskell WorkspaceLockConflict model + 409 response parser. |
| clients/haskell/sdk/Io/Superposition/Model/WorkspaceLock.hs | Adds Haskell WorkspaceLock model. |
| clients/haskell/sdk/Io/Superposition/Model/UpdateWorkspaceOutput.hs | Adds optional workspace_lock to Haskell UpdateWorkspaceOutput. |
| clients/haskell/sdk/Io/Superposition/Model/MigrateWorkspaceSchemaOutput.hs | Adds optional workspace_lock to Haskell MigrateWorkspaceSchemaOutput. |
| clients/haskell/sdk/Io/Superposition/Model/GetWorkspaceOutput.hs | Adds optional workspace_lock to Haskell GetWorkspaceOutput. |
| clients/haskell/sdk/Io/Superposition/Model/CreateWorkspaceOutput.hs | Adds optional workspace_lock to Haskell CreateWorkspaceOutput. |
| clients/haskell/sdk/Io/Superposition/Command/UpdateDefaultConfig.hs | Adds WorkspaceLockConflict handling to Haskell UpdateDefaultConfig command error parsing. |
| clients/haskell/sdk/Io/Superposition/Command/DeleteDefaultConfig.hs | Adds WorkspaceLockConflict handling to Haskell DeleteDefaultConfig command error parsing. |
| clients/haskell/sdk/Io/Superposition/Command/CreateDefaultConfig.hs | Adds WorkspaceLockConflict handling to Haskell CreateDefaultConfig command error parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @mixin | ||
| operation WorkspaceWriteOperation { | ||
| errors: [ | ||
| WorkspaceLockConflict | ||
| ] | ||
| } |
| allow_experiment_self_approval: Boolean | ||
| auto_populate_control: Boolean | ||
| enable_context_validation: Boolean | ||
| enable_change_reason_validation: Boolean | ||
| workspace_lock: WorkspaceLock | ||
| } |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
docs/docs/api/create-workspace.StatusCodes.json (1)
1-1: 💤 Low valueConsider terminology consistency: "workspace lease" vs "workspace lock".
The
workspace_lockdescription uses "workspace lease" while theWorkspaceLockConflicterror description uses "workspace lock". These terms should be consistent across the API documentation.This is likely defined in the Smithy source models, so if adjusted, it should be corrected there to propagate to all generated SDKs and documentation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/docs/api/create-workspace.StatusCodes.json` at line 1, Summary: Inconsistent terminology: "workspace lease" vs "workspace lock" across API docs; unify to "workspace lock". Fix: update the Smithy model(s) that define the CreateWorkspaceResponseContent property workspace_lock and the WorkspaceLockConflict error description so both use the same term ("workspace lock"); specifically edit the description text for the symbol workspace_lock in the CreateWorkspaceResponseContent and the WorkspaceLockConflict error model to replace "workspace lease" with "workspace lock" (or vice versa if your standard is the other term) so generated docs and SDKs are consistent.clients/haskell/sdk/Io/Superposition/Model/WorkspaceLockConflict.hs (1)
85-85: ⚡ Quick winUse idiomatic
status409instead ofmkStatus 409 "".The
Network.HTTP.Typeslibrary provides predefined status constants likestatus409that are cleaner and more idiomatic than constructing withmkStatus. While the reason phrase is ignored in equality comparisons, using the library's constants improves code clarity and consistency with standard Haskell practices.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@clients/haskell/sdk/Io/Superposition/Model/WorkspaceLockConflict.hs` at line 85, Replace the manual construction of a 409 status in the expectedStatus binding with the library constant: change the expression in expectedStatus from Network.HTTP.Types.mkStatus 409 "" to status409 (or Network.HTTP.Types.status409 if you keep the qualified name), and ensure status409 is imported from Network.HTTP.Types (or referenced qualified) so the module compiles and uses the idiomatic constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@clients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLockConflict.java`:
- Around line 169-174: The build logic in WorkspaceLockConflict marks the
required member $SCHEMA_LOCK as present via tracker.setMember($SCHEMA_LOCK)
without ensuring the field lock is non-null, so build() may produce an instance
with lock == null; update the build() method (the WorkspaceLockConflict builder)
to either assign a safe fallback to the lock field before calling
tracker.setMember($SCHEMA_LOCK) or throw an
IllegalStateException/NullPointerException if lock is missing—ensure the code
path that calls tracker.setMember($SCHEMA_LOCK) also guarantees lock is set
(check the builder's lock variable and the tracker.checkMember($SCHEMA_LOCK)
branch) so required invariants hold.
In `@crates/superposition_sdk/src/protocol_serde/shape_create_default_config.rs`:
- Around line 30-42: The new WorkspaceLockConflict match arm for
CreateDefaultConfigError builds the error payload but doesn't backfill
tmp.message from the fallback _error_message when the parsed payload lacks a
message, causing inconsistent diagnostics; update the WorkspaceLockConflict arm
(the block that uses
crate::protocol_serde::shape_workspace_lock_conflict::de_workspace_lock_conflict_json_err
and crate::serde_util::workspace_lock_conflict_correct_errors) to follow the
same pattern as adjacent arms: after output.meta(generic) and before build(),
check if tmp.message (or the builder's message field) is empty/None and if so
set it to _error_message, then call
.build().map_err(CreateDefaultConfigError::unhandled) so 409 responses get the
generic message fallback.
---
Nitpick comments:
In `@clients/haskell/sdk/Io/Superposition/Model/WorkspaceLockConflict.hs`:
- Line 85: Replace the manual construction of a 409 status in the expectedStatus
binding with the library constant: change the expression in expectedStatus from
Network.HTTP.Types.mkStatus 409 "" to status409 (or Network.HTTP.Types.status409
if you keep the qualified name), and ensure status409 is imported from
Network.HTTP.Types (or referenced qualified) so the module compiles and uses the
idiomatic constant.
In `@docs/docs/api/create-workspace.StatusCodes.json`:
- Line 1: Summary: Inconsistent terminology: "workspace lease" vs "workspace
lock" across API docs; unify to "workspace lock". Fix: update the Smithy
model(s) that define the CreateWorkspaceResponseContent property workspace_lock
and the WorkspaceLockConflict error description so both use the same term
("workspace lock"); specifically edit the description text for the symbol
workspace_lock in the CreateWorkspaceResponseContent and the
WorkspaceLockConflict error model to replace "workspace lease" with "workspace
lock" (or vice versa if your standard is the other term) so generated docs and
SDKs are consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4cacaa70-6ebc-4129-83a2-6152f48ce1a1
📒 Files selected for processing (91)
clients/haskell/sdk/Io/Superposition/Command/CreateDefaultConfig.hsclients/haskell/sdk/Io/Superposition/Command/DeleteDefaultConfig.hsclients/haskell/sdk/Io/Superposition/Command/UpdateDefaultConfig.hsclients/haskell/sdk/Io/Superposition/Model/CreateWorkspaceOutput.hsclients/haskell/sdk/Io/Superposition/Model/GetWorkspaceOutput.hsclients/haskell/sdk/Io/Superposition/Model/MigrateWorkspaceSchemaOutput.hsclients/haskell/sdk/Io/Superposition/Model/UpdateWorkspaceOutput.hsclients/haskell/sdk/Io/Superposition/Model/WorkspaceLock.hsclients/haskell/sdk/Io/Superposition/Model/WorkspaceLockConflict.hsclients/haskell/sdk/Io/Superposition/Model/WorkspaceResponse.hsclients/haskell/sdk/SuperpositionSDK.cabalclients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionAsyncClient.javaclients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionAsyncClientImpl.javaclients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionClient.javaclients/java/sdk/src/main/java/io/juspay/superposition/client/SuperpositionClientImpl.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/CreateDefaultConfig.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/CreateWorkspaceOutput.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/DeleteDefaultConfig.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/GetWorkspaceOutput.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/MigrateWorkspaceSchemaOutput.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/UpdateDefaultConfig.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/UpdateWorkspaceOutput.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/Workspace.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLock.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLockConflict.javaclients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceResponse.javaclients/javascript/sdk/src/commands/CreateDefaultConfigCommand.tsclients/javascript/sdk/src/commands/CreateWorkspaceCommand.tsclients/javascript/sdk/src/commands/DeleteDefaultConfigCommand.tsclients/javascript/sdk/src/commands/GetWorkspaceCommand.tsclients/javascript/sdk/src/commands/ListWorkspaceCommand.tsclients/javascript/sdk/src/commands/MigrateWorkspaceSchemaCommand.tsclients/javascript/sdk/src/commands/UpdateDefaultConfigCommand.tsclients/javascript/sdk/src/commands/UpdateWorkspaceCommand.tsclients/javascript/sdk/src/models/models_0.tsclients/javascript/sdk/src/protocols/Aws_restJson1.tsclients/python/sdk/superposition_sdk/_private/schemas.pyclients/python/sdk/superposition_sdk/deserialize.pyclients/python/sdk/superposition_sdk/models.pycrates/superposition_sdk/src/client/create_workspace.rscrates/superposition_sdk/src/client/get_workspace.rscrates/superposition_sdk/src/client/migrate_workspace_schema.rscrates/superposition_sdk/src/client/update_workspace.rscrates/superposition_sdk/src/error_meta.rscrates/superposition_sdk/src/operation/create_default_config.rscrates/superposition_sdk/src/operation/create_workspace/_create_workspace_output.rscrates/superposition_sdk/src/operation/delete_default_config.rscrates/superposition_sdk/src/operation/get_workspace/_get_workspace_output.rscrates/superposition_sdk/src/operation/migrate_workspace_schema/_migrate_workspace_schema_output.rscrates/superposition_sdk/src/operation/update_default_config.rscrates/superposition_sdk/src/operation/update_workspace/_update_workspace_output.rscrates/superposition_sdk/src/protocol_serde.rscrates/superposition_sdk/src/protocol_serde/shape_create_default_config.rscrates/superposition_sdk/src/protocol_serde/shape_create_workspace.rscrates/superposition_sdk/src/protocol_serde/shape_delete_default_config.rscrates/superposition_sdk/src/protocol_serde/shape_get_workspace.rscrates/superposition_sdk/src/protocol_serde/shape_migrate_workspace_schema.rscrates/superposition_sdk/src/protocol_serde/shape_update_default_config.rscrates/superposition_sdk/src/protocol_serde/shape_update_workspace.rscrates/superposition_sdk/src/protocol_serde/shape_workspace_lock.rscrates/superposition_sdk/src/protocol_serde/shape_workspace_lock_conflict.rscrates/superposition_sdk/src/protocol_serde/shape_workspace_response.rscrates/superposition_sdk/src/serde_util.rscrates/superposition_sdk/src/types.rscrates/superposition_sdk/src/types/_workspace_lock.rscrates/superposition_sdk/src/types/_workspace_response.rscrates/superposition_sdk/src/types/builders.rscrates/superposition_sdk/src/types/error.rscrates/superposition_sdk/src/types/error/_workspace_lock_conflict.rscrates/superposition_sdk/src/types/error/builders.rsdocs/docs/api/Superposition.openapi.jsondocs/docs/api/create-default-config.StatusCodes.jsondocs/docs/api/create-default-config.api.mdxdocs/docs/api/create-workspace.StatusCodes.jsondocs/docs/api/create-workspace.api.mdxdocs/docs/api/delete-default-config.StatusCodes.jsondocs/docs/api/delete-default-config.api.mdxdocs/docs/api/get-workspace.StatusCodes.jsondocs/docs/api/get-workspace.api.mdxdocs/docs/api/list-workspace.StatusCodes.jsondocs/docs/api/list-workspace.api.mdxdocs/docs/api/migrate-workspace-schema.StatusCodes.jsondocs/docs/api/migrate-workspace-schema.api.mdxdocs/docs/api/update-default-config.StatusCodes.jsondocs/docs/api/update-default-config.api.mdxdocs/docs/api/update-workspace.StatusCodes.jsondocs/docs/api/update-workspace.api.mdxsmithy/models/default-config.smithysmithy/models/main.smithysmithy/models/workspace.smithysmithy/patches/java.patch
| if (!tracker.checkMember($SCHEMA_MESSAGE)) { | ||
| message(""); | ||
| } | ||
| if (!tracker.checkMember($SCHEMA_LOCK)) { | ||
| tracker.setMember($SCHEMA_LOCK); | ||
| } |
There was a problem hiding this comment.
Required lock can become null after error correction
Line 173 marks lock as present without setting a fallback value, so build() can create a WorkspaceLockConflict with lock == null despite lock being required.
Suggested fix
if (!tracker.checkMember($SCHEMA_LOCK)) {
- tracker.setMember($SCHEMA_LOCK);
+ lock(WorkspaceLock.builder().errorCorrection().build());
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@clients/java/sdk/src/main/java/io/juspay/superposition/model/WorkspaceLockConflict.java`
around lines 169 - 174, The build logic in WorkspaceLockConflict marks the
required member $SCHEMA_LOCK as present via tracker.setMember($SCHEMA_LOCK)
without ensuring the field lock is non-null, so build() may produce an instance
with lock == null; update the build() method (the WorkspaceLockConflict builder)
to either assign a safe fallback to the lock field before calling
tracker.setMember($SCHEMA_LOCK) or throw an
IllegalStateException/NullPointerException if lock is missing—ensure the code
path that calls tracker.setMember($SCHEMA_LOCK) also guarantees lock is set
(check the builder's lock variable and the tracker.checkMember($SCHEMA_LOCK)
branch) so required invariants hold.
| "WorkspaceLockConflict" => crate::operation::create_default_config::CreateDefaultConfigError::WorkspaceLockConflict({ | ||
| #[allow(unused_mut)] | ||
| let mut tmp = | ||
| { | ||
| #[allow(unused_mut)] | ||
| let mut output = crate::types::error::builders::WorkspaceLockConflictBuilder::default(); | ||
| output = crate::protocol_serde::shape_workspace_lock_conflict::de_workspace_lock_conflict_json_err(_response_body, output).map_err(crate::operation::create_default_config::CreateDefaultConfigError::unhandled)?; | ||
| let output = output.meta(generic); | ||
| crate::serde_util::workspace_lock_conflict_correct_errors(output).build().map_err(crate::operation::create_default_config::CreateDefaultConfigError::unhandled)? | ||
| } | ||
| ; | ||
| tmp | ||
| }), |
There was a problem hiding this comment.
Preserve generic message fallback for WorkspaceLockConflict
Line 30 adds the new error mapping, but unlike adjacent arms it never backfills tmp.message from _error_message when the payload has no message. This creates inconsistent error diagnostics for 409s.
Suggested patch
"WorkspaceLockConflict" => crate::operation::create_default_config::CreateDefaultConfigError::WorkspaceLockConflict({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::WorkspaceLockConflictBuilder::default();
output = crate::protocol_serde::shape_workspace_lock_conflict::de_workspace_lock_conflict_json_err(_response_body, output).map_err(crate::operation::create_default_config::CreateDefaultConfigError::unhandled)?;
let output = output.meta(generic);
crate::serde_util::workspace_lock_conflict_correct_errors(output).build().map_err(crate::operation::create_default_config::CreateDefaultConfigError::unhandled)?
}
;
+ if tmp.message.is_none() {
+ tmp.message = _error_message;
+ }
tmp
}),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/superposition_sdk/src/protocol_serde/shape_create_default_config.rs`
around lines 30 - 42, The new WorkspaceLockConflict match arm for
CreateDefaultConfigError builds the error payload but doesn't backfill
tmp.message from the fallback _error_message when the parsed payload lacks a
message, causing inconsistent diagnostics; update the WorkspaceLockConflict arm
(the block that uses
crate::protocol_serde::shape_workspace_lock_conflict::de_workspace_lock_conflict_json_err
and crate::serde_util::workspace_lock_conflict_correct_errors) to follow the
same pattern as adjacent arms: after output.meta(generic) and before build(),
check if tmp.message (or the builder's message field) is empty/None and if so
set it to _error_message, then call
.build().map_err(CreateDefaultConfigError::unhandled) so 409 responses get the
generic message fallback.
Problem
Describe the problem you are trying to solve here
Solution
Provide a brief summary of your solution so that reviewers can understand your code
Environment variable changes
What ENVs need to be added or changed
Pre-deployment activity
Things needed to be done before deploying this change (if any)
Post-deployment activity
Things needed to be done after deploying this change (if any)
API changes
Possible Issues in the future
Describe any possible issues that could occur because of this change
Summary by CodeRabbit
New Features
WorkspaceLockConflicterror (HTTP 409) when workspace write operations conflict with existing locks from concurrent requests. Workspace responses include lock metadata (lock_id,operation,locked_by,acquired_at,expires_at) when an active lock is present.Documentation