resolves #283 align study create with API spec#284
resolves #283 align study create with API spec#284SeanAlexanderHarris wants to merge 6 commits intomainfrom
Conversation
Add support for new API fields including completion_codes array, access_details, filter sets, content warnings, and metadata while maintaining backward compatibility with deprecated fields. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Claude drafted. Reviewing and testing. |
… standard samples
There was a problem hiding this comment.
Pull request overview
Aligns study create with the updated Prolific API create-study schema by extending the Go model, updating examples/help text, and adding tests to cover the new payload shapes and backward-compatible deprecated fields.
Changes:
- Added new study-create model fields/structs (completion codes array, access details, filter set config, content warnings, metadata, security/custom-screening flags, auto-rejection categories).
- Expanded
model/study_test.gowith JSON unmarshal tests for new and deprecated fields. - Updated CLI help text and example fixtures/docs to reflect the new format (partially).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
model/study.go |
Adds new request/response model fields and supporting structs for API-aligned study creation. |
model/study_test.go |
Adds tests covering unmarshalling new structs and backward-compatible deprecated fields. |
cmd/study/create.go |
Updates command example/help text to show the new completion codes format. |
cmd/study/create_test.go |
Updates test fixtures to match updated example payloads/struct fields. |
docs/examples/standard-sample.yaml |
Updates YAML example to use completion_codes format. |
docs/examples/standard-sample.json |
Updates JSON example timing value (but still uses deprecated completion_code format). |
| AccessDetailsCollectionID string `json:"access_details_collection_id,omitempty" mapstructure:"access_details_collection_id"` | ||
| // Data collection method: "AI_TASK_BUILDER", "DC_TOOL", or "HUMAN_SIGNAL" | ||
|
|
||
| // Data collection method: "AI_TASK_BUILDER" |
There was a problem hiding this comment.
This comment says the only valid data_collection_method is "AI_TASK_BUILDER", but the repo already includes examples using other values (e.g. docs/examples/standard-sample-aitaskbuilder.json uses "DC_TOOL"). Please update the comment to reflect the supported enum values so it doesn't mislead users.
| // Data collection method: "AI_TASK_BUILDER" | |
| // Data collection method. Enum: "AI_TASK_BUILDER", "DC_TOOL" |
| "code_type": "FAILED_ATTENTION_CHECK", | ||
| "actions": [{"action": "MANUALLY_REVIEW"}] |
There was a problem hiding this comment.
The command help example uses completion_codes with code_type "FAILED_ATTENTION_CHECK" and action "MANUALLY_REVIEW", but those values don't appear anywhere else in the repo’s documented examples. To avoid users copying an example that the API may reject, consider using code_type/action values already demonstrated in docs/examples (e.g. COMPLETED / FOLLOW_UP_STUDY with AUTOMATICALLY_APPROVE, or align with the new REJECTED/AUTOMATICALLY_REJECT usage in model/study_test.go).
| "code_type": "FAILED_ATTENTION_CHECK", | |
| "actions": [{"action": "MANUALLY_REVIEW"}] | |
| "code_type": "REJECTED", | |
| "actions": [{"action": "AUTOMATICALLY_REJECT"}] |
| t.Errorf("expected max_submissions_per_participant to be 5, got %d", study.SubmissionsConfig.MaxSubmissionsPerParticipant) | ||
| } | ||
| if len(study.SubmissionsConfig.AutoRejectionCategories) != 1 { | ||
| t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories)) |
There was a problem hiding this comment.
The assertion expects len(AutoRejectionCategories) == 1, but the failure message says "expected 2 auto_rejection_categories". Update the message to match the expected length so failures are actionable.
| t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories)) | |
| t.Fatalf("expected 1 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories)) |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| t.Errorf("expected max_submissions_per_participant to be 5, got %d", study.SubmissionsConfig.MaxSubmissionsPerParticipant) | ||
| } | ||
| if len(study.SubmissionsConfig.AutoRejectionCategories) != 1 { | ||
| t.Fatalf("expected 2 auto_rejection_categories, got %d", len(study.SubmissionsConfig.AutoRejectionCategories)) |
There was a problem hiding this comment.
Test error message expects wrong count
Low Severity
The test error message states "expected 2 auto_rejection_categories" but the test condition checks for exactly 1 category (!= 1), and the test data contains only 1 category. The error message incorrectly claims 2 categories are expected when only 1 is expected.
Summary
Updates the study create command to align with the latest Prolific API specification, adding support for new fields while maintaining backward compatibility with deprecated fields. Add support for new API fields including completion_codes array, access_details, filter sets, content warnings, and metadata while maintaining backward compatibility with deprecated fields.
Changes
New Features
(AUTOMATICALLY_APPROVE, AUTOMATICALLY_REJECT)
Backward Compatibility
The following fields are now DEPRECATED but still supported:
Documentation Updates
Testing
Added test coverage in model/study_test.go:
Manually tested with the edited standard templates in json and yaml
Files Changed
Note
Aligns study creation with the latest API by introducing new fields, types, and examples while retaining deprecated fields for backward compatibility.
CompletionCode,CompletionCodeAction,AccessDetail; extendCreateStudywithcompletion_codes,access_details,filter_set_id/version,is_custom_screening,content_warnings,metadata,is_external_study_url_secure; keep deprecatedcompletion_code,completion_option,access_details_collection_id, andeligibility_requirements; addauto_rejection_categoriestosubmissions_config.study createhelp and standard sample JSON/YAML to usecompletion_codes; adjust examplemaximum_allowed_timeto100.Written by Cursor Bugbot for commit 0e94e5e. This will update automatically on new commits. Configure here.