Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

fix(athena): use the workgroup result location when the workgroup enforces its configuration (#2429)

mishukdutta-cz0791b85c4363
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21da7a5a..8b44d07a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).
## [Unreleased]
### Fixed
+- **Athena — an enforced workgroup overrides the client-side result location** — when a workgroup has `EnforceWorkGroupConfiguration: true`, `StartQueryExecution` now writes results to the workgroup's `OutputLocation`, even when the request gives its own `ResultConfiguration.OutputLocation`, as AWS does. Before, the request's location was used.
- **Lambda — a partial ARN as the `FunctionName`** — `123456789012:function:my-function[:qualifier]` resolved to the account ID as the function name, so `Invoke` and the other function operations failed with `Function not found: ...:function:123456789012`; it now resolves as the full ARN in the caller's region, as on AWS, and gives the same result as that full ARN.
## [1.5.33] — 2026-10-26
diff --git a/ministack/services/athena.py b/ministack/services/athena.py
index 9121dd23..52fd9fb1 100644
--- a/ministack/services/athena.py
+++ b/ministack/services/athena.py
@@ -819,11 +819,14 @@ def _start_query_execution(data):
query = data.get("QueryString", "")
query_id = new_uuid()
workgroup = data.get("WorkGroup", "primary")
- output_location = data.get("ResultConfiguration", {}).get(
- "OutputLocation"
- ) or _workgroups.get(workgroup, {}).get("Configuration", {}).get(
- "ResultConfiguration", {}
- ).get("OutputLocation")
+ wg_config = _workgroups.get(workgroup, {}).get("Configuration", {})
+ wg_output = wg_config.get("ResultConfiguration", {}).get("OutputLocation")
+ client_output = data.get("ResultConfiguration", {}).get("OutputLocation")
+ # An enforced workgroup overrides the client-side result location
+ if wg_config.get("EnforceWorkGroupConfiguration"):
+ output_location = wg_output or client_output
+ else:
+ output_location = client_output or wg_output
if not output_location:
return error_response_json(
"InvalidRequestException",
diff --git a/tests/test_athena.py b/tests/test_athena.py
index f31bb124..1d219e50 100644
--- a/tests/test_athena.py
+++ b/tests/test_athena.py
@@ -875,6 +875,32 @@ def test_athena_list_and_get_databases_from_glue(athena, glue):
assert err.value.response["Error"]["Code"] == "InvalidRequestException"
[email protected]("enforce,expected_prefix", [
+ (True, "s3://athena-wg-out/enforced/"),
+ (False, "s3://athena-client-out/"),
+])
+def test_athena_enforced_workgroup_overrides_client_output_location(athena, enforce, expected_prefix):
+ name = f"wg-enforce-{_uuid_mod.uuid4().hex[:8]}"
+ athena.create_work_group(
+ Name=name,
+ Configuration={
+ "EnforceWorkGroupConfiguration": enforce,
+ "ResultConfiguration": {"OutputLocation": "s3://athena-wg-out/enforced/"},
+ },
+ )
+ try:
+ qid = athena.start_query_execution(
+ QueryString="SELECT 1",
+ WorkGroup=name,
+ ResultConfiguration={"OutputLocation": "s3://athena-client-out/"},
+ )["QueryExecutionId"]
+ location = athena.get_query_execution(QueryExecutionId=qid)["QueryExecution"][
+ "ResultConfiguration"]["OutputLocation"]
+ assert location == f"{expected_prefix}{qid}.csv"
+ finally:
+ athena.delete_work_group(WorkGroup=name, RecursiveDeleteOption=True)
+
+
def test_athena_workgroup_reports_engine_version(athena):
version = athena.get_work_group(WorkGroup="primary")["WorkGroup"]["Configuration"]["EngineVersion"]
assert version["EffectiveEngineVersion"] == "Athena engine version 3"