mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
fix(python): preserve marshal scalar identity and decode limits
This commit is contained in:
@@ -19,7 +19,10 @@ import {
|
||||
AnalysisResourceConstraintError,
|
||||
AnalysisUnsupportedTargetError,
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
import type { InspectPythonPycInput } from "../domain/python/pythonPyc.js";
|
||||
import {
|
||||
PYTHON_PYC_LIMIT_MAXIMA,
|
||||
type InspectPythonPycInput,
|
||||
} from "../domain/python/pythonPyc.js";
|
||||
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
||||
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
||||
import { err, ok } from "../domain/result.js";
|
||||
@@ -38,6 +41,30 @@ export const PYTHON_PYC_PROVIDER_IDENTITY = {
|
||||
|
||||
const OPERATION = "inspect_python_pyc";
|
||||
|
||||
const parserLimitRecovery = (
|
||||
limits: PythonPycResourceFailure["reported_limits"],
|
||||
) => {
|
||||
const actions = (
|
||||
Object.keys(
|
||||
PYTHON_PYC_LIMIT_MAXIMA,
|
||||
) as (keyof typeof PYTHON_PYC_LIMIT_MAXIMA)[]
|
||||
).flatMap((field) => {
|
||||
const selected = limits[field];
|
||||
if (selected === undefined) return [];
|
||||
const maximum = PYTHON_PYC_LIMIT_MAXIMA[field];
|
||||
const option = `--${field.replaceAll("_", "-")}`;
|
||||
return [
|
||||
selected < maximum
|
||||
? `Raise ${field} (${option}) above ${selected}, up to ${maximum}, on the next call.`
|
||||
: `${field} (${option}) is at this operation's maximum of ${maximum}; select a complete artifact within that bound.`,
|
||||
];
|
||||
});
|
||||
return {
|
||||
retryable: false as const,
|
||||
remediationAction: `${actions.join(" ")} Repeating the unchanged request fails the same way; waiting or adding host memory does not raise these parser limits.`,
|
||||
};
|
||||
};
|
||||
|
||||
const failureForPrimary = (cause: unknown, input: InspectPythonPycInput) => {
|
||||
if (cause instanceof AnalysisError) return cause;
|
||||
if (cause instanceof ArtifactReaderFailure && cause.reason === "integrity")
|
||||
@@ -57,7 +84,7 @@ const failureForPrimary = (cause: unknown, input: InspectPythonPycInput) => {
|
||||
cause.boundary === "depth" ? "capacity" : "memory",
|
||||
cause.message,
|
||||
cause.reported_limits,
|
||||
{ cause },
|
||||
{ cause, ...parserLimitRecovery(cause.reported_limits) },
|
||||
);
|
||||
if (cause instanceof PythonPycFormatFailure)
|
||||
return cause.kind === "unsupported"
|
||||
@@ -81,7 +108,10 @@ const failureForPrimary = (cause: unknown, input: InspectPythonPycInput) => {
|
||||
"file-size",
|
||||
cause.message,
|
||||
{ max_file_bytes: input.max_file_bytes },
|
||||
{ cause },
|
||||
{
|
||||
cause,
|
||||
...parserLimitRecovery({ max_file_bytes: input.max_file_bytes }),
|
||||
},
|
||||
);
|
||||
if (cause.reason === "path" || cause.reason === "format")
|
||||
return new AnalysisInputError(OPERATION, { cause }, [
|
||||
|
||||
Reference in New Issue
Block a user