{"task": {"agent_timeout": 3600, "task": "task_aws_samples_serverless_test_samples__unicorn_reservation_apis", "verifier_timeout": 1800, "instruction": "You are a backend development expert. Please inspect the backend project located in the current directory, determine its programming language and architectural style, and then complete the following code implementation and environment setup tasks.\n\nUnicorn Reservation APIs \u2013 Backend Exercise\n\nYou are restoring the FastAPI-based local stub that mirrors the Unicorn Reservation System. The service reads demo data into `InventoryStore` and exposes the `/locations`, `/list/{location}`, `/checkout`, and `/geturl` endpoints. Implement the missing logic so automated tests can interact with the local server exactly like the deployed AWS stack.\n\nInventoryStore requirements\n1. `get_locations` must return a sorted list of unique `Location` values that currently exist in the in-memory `_unicorns` collection. The method must guard access with the provided threading lock.\n2. `list_by_location(location, available_only)` must perform a case-insensitive comparison on the requested location, return shallow copies of every matching unicorn record, and optionally filter to entries whose `Status` equals `\"AVAILABLE\"` when `available_only` is true.\n3. `reserve_unicorn(unicorn_name, reserved_for)` must locate a unicorn by name (case-insensitive), ensure it is marked `\"AVAILABLE\"`, update its `Status` to `\"RESERVED\"`, and set the `Reserved By` field to the provided name. Raise `ValueError` if the unicorn exists but is not available, and `KeyError` if no matching record exists.\n\nHTTP handler behavior\n1. `GET /locations` must return `{\"locations\": [...]}` by delegating to `InventoryStore.get_locations()`.\n2. `GET /list/{location}` must call `list_by_location`, honor the `available` query flag, ignore the `page_token` input, and respond with `{ \"unicorn_list\": [...], \"page_token\": \"END\" }`. Each list entry should include the same shape as stored in memory (`Name`, `Location`, `Status`, `Reserved By`).\n3. `POST /checkout` receives form fields `unicorn` and `reserved_for`. Reject blank `reserved_for` values with HTTP 400, translate `KeyError` from the store into HTTP 404, translate `ValueError` into HTTP 400, and return a plaintext body of `\"OK\"` upon success.\n4. `GET /geturl` must recreate the synthetic S3 presigned POST response used by the frontend. Build a UTC timestamp in `YYYYMMDDTHHMMSSZ` form, derive a `daily_prefix` (`YYYY/MM/DD`), and create an object key such as `\"{daily_prefix}/unicorn_load_{timestamp}_{uuid4}.csv\"`. The JSON payload must include the `url` pointing at `https://{DEFAULT_BUCKET}.s3.amazonaws.com` and a `fields` dictionary containing `key`, `x-amz-algorithm`, `x-amz-credential`, `x-amz-date`, `policy`, and `x-amz-signature` keys filled with deterministic strings that follow the original format (use the timestamp and randomly generated UUIDs just like the AWS Lambda implementation).\n\nConstraints and notes\n- Preserve the in-memory data contract so the front-end can rely on the `Reserved By` field even when a unicorn is available (use the placeholder `\"- available -\"`).\n- Keep the functions thread-safe by using the existing lock any time you read or mutate `_unicorns`.\n- Do not introduce pagination; always set `page_token` in responses to the literal string `\"END\"` for now.\n- Keep the external surface compatible with the AWS backend so integration and contract tests remain valid.\nPlease locate the appropriate place in the project and apply the necessary modifications.\n\nAfter completing all source code implementation, create a Dockerfile for this project using the following example template as a reference (Python version):\n```\n# setup base\nFROM nikolaik/python-nodejs:python3.12-nodejs22-bullseye\nRUN apt-get update && apt-get install -y sqlite3\n\n# install dependencies and copy project files\nWORKDIR /app\nCOPY . /app/\nRUN python3 -m pip install -r requirements.txt\n\nENTRYPOINT [\"python3\", \"app.py\"]\n```\nNotes:\n1. Ensure that all required project dependencies are properly installed inside the image.\n2. The generated Dockerfile must successfully build and run the application.\n3. The Dockerfile must be created in the root directory of the backend project, i.e `/app/aws-samples_serverless-test-samples/Dockerfile`\n", "memory": "", "runnable": false, "difficulty": "hard", "language": "", "cpus": "", "instruction_truncated": false, "category": "Infrastructure", "compose": true, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "abc-bench", "tags": []}, "runs": []}