(c *gin.Context)
| 1015 | } |
| 1016 | if _, ok := fields["data_imports_table_naming_version"]; ok { |
| 1017 | if err := validateDataImportsTableNamingVersion(updates.DataImportsTableNamingVersion); err != nil { |
| 1018 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 1019 | return |
| 1020 | } |
| 1021 | } |
| 1022 | existing, err := h.store.GetOrg(name) |
| 1023 | if err != nil { |
| 1024 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 1025 | c.JSON(http.StatusNotFound, gin.H{"error": "org not found"}) |
| 1026 | return |
| 1027 | } |
| 1028 | c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) |
| 1029 | return |
| 1030 | } |
| 1031 | merged := *existing |
| 1032 | // database_name is presence-aware like every other column: absent keeps the |
| 1033 | // stored value; a present value must be a valid DNS label (it becomes the |
| 1034 | // org's hostname). This is the break-glass edit surface for orgs whose |
| 1035 | // stored name predates the DNS-label rule and is therefore unroutable — |
| 1036 | // rename and the hostname works the moment the snapshot reloads. |
| 1037 | if _, ok := fields["database_name"]; ok { |
| 1038 | // Trim whitespace around the operator's value before validating/ |
| 1039 | // storing so " acme" 400s with the real problem instead of storing a |
| 1040 | // subtly different name than the operator typed and saw validated. |
| 1041 | updates.DatabaseName = strings.TrimSpace(updates.DatabaseName) |
| 1042 | if err := configstore.ValidateDatabaseName(updates.DatabaseName); err != nil { |
| 1043 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 1044 | return |
| 1045 | } |
| 1046 | merged.DatabaseName = updates.DatabaseName |
| 1047 | } |
| 1048 | if _, ok := fields["max_workers"]; ok { |
| 1049 | merged.MaxWorkers = updates.MaxWorkers |
| 1050 | } |
| 1051 | if _, ok := fields["max_vcpus"]; ok { |
| 1052 | merged.MaxVCPUs = updates.MaxVCPUs |
| 1053 | } |
| 1054 | // Org default worker profile: present-in-payload wins, including an |
| 1055 | // explicit "" which clears the default. |
| 1056 | if _, ok := fields["default_worker_cpu"]; ok { |
| 1057 | merged.DefaultWorkerCPU = updates.DefaultWorkerCPU |
| 1058 | } |
| 1059 | if _, ok := fields["default_worker_memory"]; ok { |
| 1060 | merged.DefaultWorkerMemory = updates.DefaultWorkerMemory |
| 1061 | } |
| 1062 | if _, ok := fields["default_worker_ttl"]; ok { |
| 1063 | merged.DefaultWorkerTTL = updates.DefaultWorkerTTL |
| 1064 | } |
| 1065 | if _, ok := fields["default_worker_min_hot_idle"]; ok { |
no test coverage detected