fix(12.2): close code-review blockers on uploads, JSON caps, and pivot fill
Keep form save behind in-flight uploads, make retries idempotent via X-Upload-Id, cap remaining JSON bodies, and surface pending pivot type errors instead of zeroing them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -69,8 +69,9 @@ func (k DeferredKey) validate() error {
|
||||
// holds the pivot values of a deferred belongsToMany link. A binding without
|
||||
// the envelope (nil pivot_data, or JSON without these keys) is a plain link.
|
||||
type DeferredEnvelope struct {
|
||||
Created bool `json:"created,omitempty"`
|
||||
Pivot map[string]any `json:"pivot,omitempty"`
|
||||
Created bool `json:"created,omitempty"`
|
||||
Pivot map[string]any `json:"pivot,omitempty"`
|
||||
UploadID string `json:"upload_id,omitempty"`
|
||||
}
|
||||
|
||||
// Envelope decodes the binding's pivot_data. Nil or empty pivot_data is the
|
||||
@@ -167,7 +168,7 @@ func insertBinding(ctx context.Context, tx *gorm.DB, key DeferredKey, field, sla
|
||||
IsBind: bind,
|
||||
BackendUserID: key.AdminID,
|
||||
}
|
||||
if env != nil && (env.Created || len(env.Pivot) > 0) {
|
||||
if env != nil && (env.Created || len(env.Pivot) > 0 || env.UploadID != "") {
|
||||
raw, err := json.Marshal(env)
|
||||
if err != nil {
|
||||
return fmt.Errorf("lagoon: deferred binding envelope: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user