Skip to content

fix(tasks): a question named like a task's expanded question is refused - #59

Merged
rkinas merged 1 commit into
rkinas:mainfrom
dkoryto:fix-task-subquestion-names
Nov 2, 2026
Merged

rkinas merged 1 commit into
rkinas:mainfrom
dkoryto:fix-task-subquestion-names

Conversation

@dkoryto

@dkoryto dkoryto commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A task question is expanded into decision questions named <task>::<part> (tasks.SEP). tasks.expand refuses :: in a task question's name, but not in a decision question's, so a decision question can carry the name of a task's expanded question. On main, through http_app:

{"state": "Invoice 1240 PLN.", "questions": {
  "task": {"type": "classify", "labels": {"invoice": "an invoice", "letter": "a letter"}},
  "task::labels": {"type": "choice", "instructions": "Which colour?", "criteria": {"red": "Red", "blue": "Blue"}}}}

answers 200 with {"task": {"type": "classify", "label": "red", ...}}: the classification is the colour question's answer, and task::labels has no answer at all. Found by Sourcery in its review of #58; it is in the server, not the client (a plain HTTP request does the same).

Change

  • tasks.expand: in a request with task questions, any question name containing :: is refused (HTTP 422, through reads_request), with the message saying why. Requests without task questions are not expanded and keep accepting :: in names.
  • tests/test_tasks.py: the colliding request is refused; a :: name without task questions is still answered.
  • TASKS.md states the rule; WHATS_NEW.md entry.

Validation

  • The request above: 422, question 'task::labels': in a request with task questions, a question's name may not contain '::'.
  • The whole suite: 761 passed, 53 skipped (macOS, Python 3.13).

Summary by Sourcery

Prevent task-expanded question name collisions by reserving :: in requests that contain task questions.

Bug Fixes:

  • Reject question names containing :: whenever a request includes task questions, preventing decision questions from colliding with task-expanded questions and receiving incorrect answers.

Documentation:

  • Document the reserved :: naming rule for requests containing task questions and record the fix in the changelog.

Tests:

  • Add coverage for conflicting task and decision question names, while preserving :: support when no task questions are present.

In a request with task questions, a decision question named
<task>::<part> took the place of the task's own expanded question: the
task read its answer and the question's answer was dropped. Every name
with :: is now refused there (HTTP 422), as task names already were.
@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR closes a task-expansion name collision by reserving ::-containing question names across requests with task questions, while retaining existing behavior for requests without tasks; tests and user-facing documentation cover the rule and regression.

Sequence diagram for task question name collision validation

sequenceDiagram
    participant Client
    participant reads_request
    participant tasks_expand
    participant HTTP

    Client->>reads_request: submit request
    reads_request->>tasks_expand: expand(body)
    tasks_expand->>tasks_expand: inspect question names
    alt task question present and name contains ::
        tasks_expand-->>reads_request: raise ValueError
        reads_request-->>HTTP: HTTP 422
        HTTP-->>Client: question name may not contain ::
    else no task question
        tasks_expand-->>reads_request: keep questions unchanged
        reads_request-->>Client: answer request
    end
Loading

File-Level Changes

Change Details Files
Reject separator-containing question names whenever task expansion is active, preventing decision questions from colliding with generated task question names.
  • Move the separator-name validation ahead of the task/non-task branch so it applies to every question in requests containing tasks.
  • Preserve acceptance of :: names when no task questions are present.
  • Add regression coverage for the collision and the no-task compatibility case.
basal/tasks.py
tests/test_tasks.py
Document the naming restriction and the resulting HTTP behavior for task requests.
  • Explain that task expansion reserves <name>::<part> names and produces HTTP 422 for violations.
  • Record the bug fix and its previously incorrect answer-mapping behavior in the unreleased changes.
docs/TASKS.md
docs/WHATS_NEW.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@rkinas

rkinas commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thank you, Dariusz! Merged into the basal 2.5 release branch with your commit as you wrote it. The full CPU suite and your tests pass, and every answer to our identity and router request sets is byte-identical to the branch before the merge. The PR will close when 2.5 is published on main.

@rkinas
rkinas merged commit 376df69 into rkinas:main Nov 2, 2026
1 check passed
rkinas added a commit that referenced this pull request Nov 2, 2026
… version

CONTRIBUTING.md credits the 2.5 pull requests as the release notes' community line lists them (Paweł Kiszczak
#52, #62, #64, #66, #68, #71, #73, #75; Marcin Brzeżański #56; Grzegorz Brzezinka #76, #78) and adds Dariusz
Koryto (#53, #58, #59, #60 and #55); the README's list names him too. docs/changes/README.md and the
changelog.py help use 2.5.1, the next release, as the example.
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.

2 participants