Skip to content

✨feat: include workspace_slug in dynamic context and co id - #20

Merged
alain-sv merged 1 commit into
developfrom
workspace_slug
Apr 11, 2026
Merged

✨feat: include workspace_slug in dynamic context and co id#20
alain-sv merged 1 commit into
developfrom
workspace_slug

Conversation

@alain-sv

Copy link
Copy Markdown
Contributor

No description provided.

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Include workspace_slug in dynamic choices context

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add workspace_slug to dynamic choices callback context
• Implement workspace_id type coercion from int to string
• Update documentation and API descriptions for workspace context
• Expand test coverage for new context parameter
Diagram
flowchart LR
  A["Dynamic Choices Request"] -->|"includes workspace_slug"| B["Request Body"]
  B -->|"extracted"| C["Context Dict"]
  C -->|"passed to"| D["dynamic_choices_callback"]
  E["workspace_id int"] -->|"coerced to str"| F["JobContext"]
Loading

Grey Divider

File Changes

1. src/supervaizer/agent.py 📝 Documentation +1/-1

Document workspace_slug in callback context

• Updated dynamic_choices_callback field description to document that context includes
 workspace_id, workspace_slug, and mission_id

src/supervaizer/agent.py


2. src/supervaizer/job.py ✨ Enhancement +12/-0

Add workspace_id type coercion validator

• Added pydantic.field_validator import
• Implemented coerce_workspace_id validator to normalize numeric workspace IDs to strings
• Handles int, float, and string types with string trimming

src/supervaizer/job.py


3. src/supervaizer/routes.py ✨ Enhancement +2/-1

Pass workspace_slug to dynamic choices context

• Updated endpoint description to mention workspace slug in context
• Modified get_dynamic_choices to extract and pass workspace_slug from request body to context
 dict

src/supervaizer/routes.py


View more (5)
4. tests/test_job.py 🧪 Tests +12/-0

Test workspace_id integer coercion

• Added new test test_job_context_workspace_id_int_coerced_to_str to verify integer workspace IDs
 are converted to strings

tests/test_job.py


5. tests/test_routes.py 🧪 Tests +58/-4

Test workspace_slug in dynamic choices endpoint

• Updated existing dynamic choices tests to include workspace_slug in request JSON
• Added new test test_dynamic_choices_endpoint_passes_workspace_slug_in_context to verify
 workspace_slug is passed through callback context
• Updated test data across multiple test functions to include workspace_slug parameter

tests/test_routes.py


6. AGENTS.md 📝 Documentation +7/-0

Document workspace facts and admin IP restrictions

• Added new sections for "Learned User Preferences" and "Learned Workspace Facts"
• Documented ADMIN_ALLOWED_IPS environment variable behavior and IP allowlist restrictions
• Added note about token fallback differences between supervaizer and agent_interviewer

AGENTS.md


7. docs/CHANGELOG.md 📝 Documentation +17/-2

Update changelog with workspace_slug changes

• Added "Changed" section documenting workspace_slug addition to dynamic choices context
• Updated v0.13.1 release notes to include workspace_slug in endpoint documentation
• Added unit test results table showing 466 passed tests
• Clarified that Supervaize Studio sends workspace_slug in request body

docs/CHANGELOG.md


8. docs/api/openapi.json 📝 Documentation +1/-1

Update OpenAPI documentation

• Updated OpenAPI description for dynamic_choices endpoint to mention workspace slug in context

docs/api/openapi.json


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Apr 11, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ≡ Correctness (1)

Grey Divider


Action required

1. Bool workspace_id coerced 🐞
Description
JobContext.coerce_workspace_id treats bool as an int and converts True/False into string workspace
IDs ("True"/"False"), silently accepting invalid input. This can create jobs with incorrect
workspace_id values instead of failing validation.
Code

src/supervaizer/job.py[R171-172]

+        if isinstance(v, (int, float)):
+            return str(v)
Evidence
The validator converts any (int, float) to str; in Python, bool is a subclass of int, so booleans
will enter this branch and be converted to strings, bypassing the intended "workspace_id: str"
validation.

src/supervaizer/job.py[155-173]
src/supervaizer/job.py[171-172]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`JobContext.coerce_workspace_id` currently coerces any `(int, float)` to `str`. Because `bool` is an `int` subclass in Python, `workspace_id=True/False` will be accepted and converted to `"True"`/`"False"`, silently producing invalid workspace identifiers.

## Issue Context
`JobContext.workspace_id` is declared as `str`, so non-string values should either be normalized safely (for numeric IDs) or rejected when clearly invalid (like booleans).

## Fix Focus Areas
- src/supervaizer/job.py[165-173]

### Suggested change
Add an explicit `bool` guard before the numeric coercion, e.g.:
- if `isinstance(v, bool)`: raise `ValueError` (or return `v` and let Pydantic reject it)
- then handle `(int, float)` coercion

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@alain-sv
alain-sv merged commit 111054f into develop Apr 11, 2026
5 checks passed
@alain-sv
alain-sv deleted the workspace_slug branch April 11, 2026 20:42
Comment thread src/supervaizer/job.py
Comment on lines +171 to +172
if isinstance(v, (int, float)):
return str(v)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Bool workspace_id coerced 🐞 Bug ≡ Correctness

JobContext.coerce_workspace_id treats bool as an int and converts True/False into string workspace
IDs ("True"/"False"), silently accepting invalid input. This can create jobs with incorrect
workspace_id values instead of failing validation.
Agent Prompt
## Issue description
`JobContext.coerce_workspace_id` currently coerces any `(int, float)` to `str`. Because `bool` is an `int` subclass in Python, `workspace_id=True/False` will be accepted and converted to `"True"`/`"False"`, silently producing invalid workspace identifiers.

## Issue Context
`JobContext.workspace_id` is declared as `str`, so non-string values should either be normalized safely (for numeric IDs) or rejected when clearly invalid (like booleans).

## Fix Focus Areas
- src/supervaizer/job.py[165-173]

### Suggested change
Add an explicit `bool` guard before the numeric coercion, e.g.:
- if `isinstance(v, bool)`: raise `ValueError` (or return `v` and let Pydantic reject it)
- then handle `(int, float)` coercion

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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