Feat v0.9.2 Starlark converter consolidation + snapshot cleanup (#75)
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m43s
CI/CD / test-sqlite (pull_request) Successful in 2m52s
CI/CD / build-and-deploy (pull_request) Successful in 2m15s
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m43s
CI/CD / test-sqlite (pull_request) Successful in 2m52s
CI/CD / build-and-deploy (pull_request) Successful in 2m15s
Consolidate duplicate Go↔Starlark converters into sandbox/convert.go and snapshot parsers into models/snapshot.go. Standardize snapshot creation on wrapped format. Net -393 lines across 21 files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
server/models/snapshot.go
Normal file
25
server/models/snapshot.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ParseSnapshotStages parses a version snapshot into a slice of
|
||||
// WorkflowStage. It handles both the wrapped format
|
||||
// {"stages": [...], "workflow": {...}} and the legacy flat array [...].
|
||||
func ParseSnapshotStages(raw json.RawMessage) ([]WorkflowStage, error) {
|
||||
// Try wrapped format first
|
||||
var wrapped struct {
|
||||
Stages []WorkflowStage `json:"stages"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &wrapped); err == nil && len(wrapped.Stages) > 0 {
|
||||
return wrapped.Stages, nil
|
||||
}
|
||||
// Fallback to flat array
|
||||
var stages []WorkflowStage
|
||||
if err := json.Unmarshal(raw, &stages); err != nil {
|
||||
return nil, fmt.Errorf("corrupt version snapshot: %w", err)
|
||||
}
|
||||
return stages, nil
|
||||
}
|
||||
Reference in New Issue
Block a user