Proxy Saving and UX Fixes (#4467)
This commit is contained in:
@@ -124,7 +124,7 @@ export function GeoTargetSelector({
|
|||||||
<CommandGroup heading="Countries">
|
<CommandGroup heading="Countries">
|
||||||
{results.countries.map((item) => (
|
{results.countries.map((item) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={`country-${item.value.country}`}
|
key={`country-${item.value.country}${item.value.isISP ? "-isp" : ""}`}
|
||||||
value={JSON.stringify(item.value)}
|
value={JSON.stringify(item.value)}
|
||||||
onSelect={() => handleSelect(item)}
|
onSelect={() => handleSelect(item)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ function compareWorkflowBlocks(
|
|||||||
|
|
||||||
function getWorkflowElements(version: WorkflowVersion) {
|
function getWorkflowElements(version: WorkflowVersion) {
|
||||||
const settings: WorkflowSettings = {
|
const settings: WorkflowSettings = {
|
||||||
proxyLocation: version.proxy_location || ProxyLocation.Residential,
|
proxyLocation: version.proxy_location ?? ProxyLocation.Residential,
|
||||||
webhookCallbackUrl: version.webhook_callback_url || "",
|
webhookCallbackUrl: version.webhook_callback_url || "",
|
||||||
persistBrowserSession: version.persist_browser_session,
|
persistBrowserSession: version.persist_browser_session,
|
||||||
model: version.model,
|
model: version.model,
|
||||||
|
|||||||
@@ -956,7 +956,7 @@ function Workspace({
|
|||||||
// Load the selected version into the main editor
|
// Load the selected version into the main editor
|
||||||
const settings: WorkflowSettings = {
|
const settings: WorkflowSettings = {
|
||||||
proxyLocation:
|
proxyLocation:
|
||||||
selectedVersion.proxy_location || ProxyLocation.Residential,
|
selectedVersion.proxy_location ?? ProxyLocation.Residential,
|
||||||
webhookCallbackUrl: selectedVersion.webhook_callback_url || "",
|
webhookCallbackUrl: selectedVersion.webhook_callback_url || "",
|
||||||
persistBrowserSession: selectedVersion.persist_browser_session,
|
persistBrowserSession: selectedVersion.persist_browser_session,
|
||||||
model: selectedVersion.model,
|
model: selectedVersion.model,
|
||||||
@@ -1660,7 +1660,7 @@ function Workspace({
|
|||||||
|
|
||||||
const settings: WorkflowSettings = {
|
const settings: WorkflowSettings = {
|
||||||
proxyLocation:
|
proxyLocation:
|
||||||
saveData?.settings.proxyLocation || ProxyLocation.Residential,
|
saveData?.settings.proxyLocation ?? ProxyLocation.Residential,
|
||||||
webhookCallbackUrl: saveData?.settings.webhookCallbackUrl || "",
|
webhookCallbackUrl: saveData?.settings.webhookCallbackUrl || "",
|
||||||
persistBrowserSession:
|
persistBrowserSession:
|
||||||
saveData?.settings.persistBrowserSession ?? false,
|
saveData?.settings.persistBrowserSession ?? false,
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ function compareWorkflowBlocks(
|
|||||||
|
|
||||||
function getWorkflowElements(version: WorkflowVersion) {
|
function getWorkflowElements(version: WorkflowVersion) {
|
||||||
const settings: WorkflowSettings = {
|
const settings: WorkflowSettings = {
|
||||||
proxyLocation: version.proxy_location || ProxyLocation.Residential,
|
proxyLocation: version.proxy_location ?? ProxyLocation.Residential,
|
||||||
webhookCallbackUrl: version.webhook_callback_url || "",
|
webhookCallbackUrl: version.webhook_callback_url || "",
|
||||||
persistBrowserSession: version.persist_browser_session,
|
persistBrowserSession: version.persist_browser_session,
|
||||||
model: version.model,
|
model: version.model,
|
||||||
|
|||||||
@@ -149,6 +149,15 @@ export function geoTargetToProxyLocationInput(
|
|||||||
return ProxyLocation.ResidentialISP;
|
return ProxyLocation.ResidentialISP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Guard against malformed subdivision (e.g., boolean instead of string)
|
||||||
|
if (target.subdivision != null && typeof target.subdivision !== "string") {
|
||||||
|
console.error(
|
||||||
|
"[geoTargetToProxyLocationInput] Invalid subdivision:",
|
||||||
|
target.subdivision,
|
||||||
|
);
|
||||||
|
target = { ...target, subdivision: undefined };
|
||||||
|
}
|
||||||
|
|
||||||
// Try to map back to legacy enum if it's just a country
|
// Try to map back to legacy enum if it's just a country
|
||||||
if (target.country && !target.subdivision && !target.city) {
|
if (target.country && !target.subdivision && !target.city) {
|
||||||
const legacyLocation = COUNTRY_TO_PROXY_LOCATION[target.country];
|
const legacyLocation = COUNTRY_TO_PROXY_LOCATION[target.country];
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ def _deserialize_proxy_location(value: str | None) -> ProxyLocationInput:
|
|||||||
if value.startswith("{"):
|
if value.startswith("{"):
|
||||||
try:
|
try:
|
||||||
data = json.loads(value)
|
data = json.loads(value)
|
||||||
|
# Handle malformed subdivision (e.g., boolean instead of string)
|
||||||
|
subdivision = data.get("subdivision")
|
||||||
|
if subdivision is not None and not isinstance(subdivision, str):
|
||||||
|
LOG.warning("Malformed subdivision in proxy_location", db_value=value, subdivision=subdivision)
|
||||||
|
data["subdivision"] = None
|
||||||
result = GeoTarget.model_validate(data)
|
result = GeoTarget.model_validate(data)
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Deserialized proxy_location as GeoTarget",
|
"Deserialized proxy_location as GeoTarget",
|
||||||
@@ -116,8 +121,8 @@ def _deserialize_proxy_location(value: str | None) -> ProxyLocationInput:
|
|||||||
result=str(result),
|
result=str(result),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
except (json.JSONDecodeError, ValueError):
|
except (json.JSONDecodeError, ValueError) as e:
|
||||||
pass
|
LOG.warning("Failed to parse proxy_location as GeoTarget", db_value=value, error=str(e))
|
||||||
|
|
||||||
# Try as ProxyLocation enum
|
# Try as ProxyLocation enum
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user