Skip to content

FIX: Apply the request limits to the remaining request fields - #3174

Open
varunj-msft wants to merge 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/10765-New-Field-Limits
Open

varunj-msft wants to merge 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/10765-New-Field-Limits

Conversation

@varunj-msft

Copy link
Copy Markdown
Contributor

Description

#2960 added request limits, but some fields didn't get them: fields added since (conversion markers in #3002, technique creation in #3047, seed browsing in #2989) and fields from PRs that landed while #2960 was open (the scorer API in #2990, async message sends in #2861, conversation save in #2853). Separately, #2960 declared conversation_id on GET /api/attacks/{attack_result_id}/messages as IdentifierStr = Query(...), and FastAPI drops the length limit of an annotated alias on a required query parameter, so any length reached the service.

These now return 422 above the existing limits:

  • start_token and end_token on add-message and converter preview: identifier length.
  • POST /api/techniques: params keys, converter names, and adversarial_chat (identifier length), and description (text length). The adversarial prompts stay limited only by the body size, like other prompt content.
  • GET /api/datasets/seeds and /seeds/{example_id}: selection_key (cursor length) and harm_category values (label value length).
  • Message-send path ids.
  • Scorers: type, params keys and count, cursor, and scorer_registry_name, matching targets and converters.
  • target_registry_name on POST /api/attacks/save-conversation.
  • conversation_id: the limit is set on the Query itself.

Not included: GET /api/media?path (bounded by the URL length limit) and the label filters (checked by their validator).

Tests and Documentation

  • test_common_models.py, test_api_routes.py, test_message_send_routes.py, test_scorer_routes.py, test_seed_example_routes.py: each added limit rejects one character or item over, and the routes return 422 before the service is called, including an over-long conversation_id.
  • test_common_models.py also checks that technique fields accept values at the limit while the adversarial prompts stay unbounded.
    No JupyText changes.

Conversion markers, technique creation fields, seed browsing filters, message-send ids, the scorer routes, and the save-conversation target name accepted values of any length, and the conversation_id filter for attack messages lost its limit because a Query default replaced the annotated one. They now use the shared limits and return 422.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant