fix(ci): hotfix Compaction Tests smoke test broken on main by fast-fail compaction (#11547)

Signed-off-by: Michael Neale <michael.neale@gmail.com>

Merging as these tests are run on main and only with PRs from maintainers, so it can slip in.
This commit is contained in:
Michael Neale
2026-08-25 13:44:11 +10:00
committed by GitHub
parent 98dd5305b9
commit 65838e9fb7
2 changed files with 112 additions and 6 deletions
+70 -2
View File
@@ -62,6 +62,42 @@ ALWAYS_FORWARD_PATHS = [
'/api/2.0/', # Databricks management API
]
# Path fragments identifying an inference/completion request.
#
# Error injection only applies to these. Every error mode the proxy offers
# describes a completion failure (context length exceeded, rate limited,
# upstream 500), so injecting them into metadata traffic such as model listing
# is meaningless. It is also actively harmful in count mode: a pre-flight
# request would silently consume the error budget intended for a completion,
# making "inject N errors" depend on goose's incidental call pattern rather
# than on the completions the test is actually exercising.
COMPLETION_PATHS = [
'/chat/completions', # OpenAI and compatible
'/completions', # OpenAI legacy
'/messages', # Anthropic
'/responses', # OpenAI Responses API
':generatecontent', # Google Gemini
':streamgeneratecontent',
'/converse', # Bedrock
'/invoke', # Bedrock / Databricks serving
'/invocations',
'/serving-endpoints', # Databricks
]
# Path suffixes identifying known non-inference (metadata) traffic. Used as
# the exclusion list when classifying requests that do not match
# COMPLETION_PATHS: a POST to an unrecognized path (e.g. a provider configured
# with a custom inference base path) is still treated as a completion, but
# known metadata endpoints are not. Matched as suffixes, not substrings, so a
# custom inference path that merely contains one of these segments (e.g.
# /v1/models/my-model/predict) is still classified as a completion.
METADATA_PATH_SUFFIXES = [
'/models', # model listing (OpenAI-compatible)
'/api/tags', # Ollama model listing
'/api/show', # Ollama model info (POSTed before completions for context limits)
'/embeddings', # embeddings are not turn completions
]
class ErrorMode(Enum):
"""Error injection modes."""
@@ -383,7 +419,33 @@ class ErrorProxy:
for forward_path in ALWAYS_FORWARD_PATHS:
if forward_path in path:
return True
return False
return not self.is_completion_request(request)
def is_completion_request(self, request: Request) -> bool:
"""
Check whether this request is an inference/completion call.
Only completion requests are eligible for error injection; see
COMPLETION_PATHS.
Args:
request: The incoming HTTP request
Returns:
True if this is a completion request
"""
path = request.path.lower()
if any(fragment in path for fragment in COMPLETION_PATHS):
return True
# Providers configured with a custom inference base path (e.g. an
# OpenAI-compatible endpoint at "<project_id>/v1") post completions to
# routes that match none of the known fragments. Treat any other POST
# that is not known metadata traffic as a completion so error
# injection still applies to custom inference routes.
if request.method.upper() != 'POST':
return False
path = path.rstrip('/')
return not any(path.endswith(suffix) for suffix in METADATA_PATH_SUFFIXES)
def get_target_url(self, request: Request, provider: str) -> str:
"""
@@ -462,7 +524,13 @@ class ErrorProxy:
# Check if this request should always be forwarded
if self.should_always_forward(request):
logger.info(f"🔄 Always forwarding: {request.path}")
if self.is_completion_request(request):
logger.info(f"🔄 Always forwarding: {request.path}")
else:
logger.info(
f"🔄 Forwarding non-completion request (not eligible for "
f"error injection): {request.path}"
)
else:
# Capture the error mode BEFORE checking if we should inject (since that modifies state)
mode_before_check = self.get_error_mode()