Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions client/payloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,13 @@ type InstructionOption struct {
Heading string `json:"heading,omitempty"`
}

// AnswerLimit represents the answer limit for multiple choice with free text instructions
type AnswerLimit struct {
Type string `json:"type"`
Description string `json:"description"`
}

// Instruction represents a single instruction in the request payload
type Instruction struct {
Type InstructionType `json:"type"`
CreatedBy string `json:"created_by"`
Description string `json:"description"`
Options []InstructionOption `json:"options,omitempty"`
AnswerLimit *AnswerLimit `json:"answer_limit,omitempty"`
AnswerLimit *int `json:"answer_limit,omitempty"`
}

// CreateAITaskBuilderInstructionsPayload represents the JSON payload for creating AI Task Builder instructions
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/batch_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ prolific aitaskbuilder batch create -n "My Data Collection Batch" -w 6278acb09

err := createAITaskBuilderBatch(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/batch_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestNewBatchCreateCommandAPIError(t *testing.T) {
t.Fatal("expected error; got nil")
}

expectedError := "error: API error"
expectedError := "API error"
if err.Error() != expectedError {
t.Fatalf("expected error: %s; got %s", expectedError, err.Error())
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/aitaskbuilder/batch_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Example instructions.json:
"label": "Response 2",
"value": "response2"
}
]
],
"answer_limit": 1
},
{
"type": "free_text",
Expand All @@ -72,7 +73,7 @@ Example instructions.json:

err := createBatchInstructions(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/batch_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ prolific aitaskbuilder batch setup -b <batch_id> -d <dataset_id> --tasks-per-g

err := setupAITaskBuilderBatch(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/aitaskbuilder/batch_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestNewBatchSetupCommandAPIError(t *testing.T) {
t.Fatal("expected error; got nil")
}

expectedError := "error: API error"
expectedError := "API error"
if err.Error() != expectedError {
t.Fatalf("expected error: %s; got %s", expectedError, err.Error())
}
Expand Down Expand Up @@ -198,12 +198,12 @@ func TestNewBatchSetupCommandInvalidTasksPerGroup(t *testing.T) {
{
name: "zero tasks per group",
tasksPerGroup: "0",
expectedErr: "error: " + aitaskbuilder.ErrTasksPerGroupMinimum,
expectedErr: "" + aitaskbuilder.ErrTasksPerGroupMinimum,
},
{
name: "negative tasks per group",
tasksPerGroup: "-1",
expectedErr: "error: " + aitaskbuilder.ErrTasksPerGroupMinimum,
expectedErr: "" + aitaskbuilder.ErrTasksPerGroupMinimum,
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/batch_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ prolific aitaskbuilder batch tasks -b <batch_id>

err := renderAITaskBuilderTasks(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/aitaskbuilder/batch_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -130,7 +129,7 @@ func TestNewBatchTasksCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("batch-id", batchID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -151,7 +150,7 @@ func TestNewBatchTasksCommandRequiresBatchID(t *testing.T) {

if !cmd.Flags().Changed("batch-id") {
expected := aitaskbuilder.ErrBatchIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/create_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ prolific aitaskbuilder dataset create -n "test" -w <workspace_id>

err := createAITaskBuilderDataset(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
7 changes: 3 additions & 4 deletions cmd/aitaskbuilder/create_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -106,7 +105,7 @@ func TestNewCreateDatasetCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("workspace-id", "invalid-workspace")
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -128,7 +127,7 @@ func TestNewCreateDatasetCommandRequiresName(t *testing.T) {

if !cmd.Flags().Changed("name") {
expected := aitaskbuilder.ErrNameRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand All @@ -149,7 +148,7 @@ func TestNewCreateDatasetCommandRequiresWorkspaceID(t *testing.T) {

if !cmd.Flags().Changed("workspace-id") {
expected := aitaskbuilder.ErrWorkspaceIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/get_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ prolific aitaskbuilder batch view -b <batch_id>

err := renderAITaskBuilderBatch(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/get_batch_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ prolific aitaskbuilder batch check -b <batch_id>

err := renderAITaskBuilderBatchStatus(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/aitaskbuilder/get_batch_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -90,7 +89,7 @@ func TestNewGetBatchStatusCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("batch-id", batchID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -111,7 +110,7 @@ func TestNewGetBatchStatusCommandRequiresBatchID(t *testing.T) {

if !cmd.Flags().Changed("batch-id") {
expected := aitaskbuilder.ErrBatchIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/aitaskbuilder/get_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"
"time"
Expand Down Expand Up @@ -181,7 +180,7 @@ func TestNewGetBatchCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("batch-id", batchID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -202,7 +201,7 @@ func TestNewGetBatchCommandRequiresBatchID(t *testing.T) {

if !cmd.Flags().Changed("batch-id") {
expected := aitaskbuilder.ErrBatchIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
Copy link
Contributor

@benmatselby benmatselby Dec 8, 2025

Choose a reason for hiding this comment

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

question: Do we need the empty string concatenation? Same question in a few test files

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot guys.. will yeet.

t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/get_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $ prolific aitaskbuilder batch list -w <workspace_id>

err := renderAITaskBuilderBatches(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/aitaskbuilder/get_batches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"
"time"
Expand Down Expand Up @@ -127,7 +126,7 @@ func TestNewGetBatchesCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("workspace-id", workspaceID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -148,7 +147,7 @@ func TestNewGetBatchesCommandRequiresWorkspaceID(t *testing.T) {

if !cmd.Flags().Changed("workspace-id") {
expected := "workspace ID is required"
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/get_dataset_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ prolific aitaskbuilder dataset check -d <dataset_id>

err := renderAITaskBuilderDatasetStatus(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/aitaskbuilder/get_dataset_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestNewGetDatasetStatusCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("dataset-id", datasetID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -136,7 +136,7 @@ func TestNewGetDatasetStatusCommandRequiresDatasetID(t *testing.T) {

if !cmd.Flags().Changed("dataset-id") {
expected := aitaskbuilder.ErrDatasetIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/get_task_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ prolific aitaskbuilder batch responses -b <batch_id>

err := renderAITaskBuilderResponses(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
5 changes: 2 additions & 3 deletions cmd/aitaskbuilder/get_task_responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"
"time"
Expand Down Expand Up @@ -208,7 +207,7 @@ func TestNewGetResponsesCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("batch-id", batchID)
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand All @@ -229,7 +228,7 @@ func TestNewGetResponsesCommandRequiresBatchID(t *testing.T) {

if !cmd.Flags().Changed("batch-id") {
expected := aitaskbuilder.ErrBatchIDRequired
if err.Error() != "error: "+expected {
if err.Error() != ""+expected {
t.Fatalf("expected error to contain '%s', got '%s'", expected, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aitaskbuilder/upload_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ prolific aitaskbuilder dataset upload -d <dataset_id> -f docs/examples/aitb-mo

err := uploadDatasetFile(client, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions cmd/campaign/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $ prolific campaign list -w <workspace_id> -l 1 -o 2

err := renderCampaigns(c, opts, w)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand All @@ -75,14 +75,14 @@ func renderCampaigns(c client.API, opts CampaignListOptions, w io.Writer) error
}

tw := tabwriter.NewWriter(w, 0, 1, 1, ' ', 0)
fmt.Fprintf(tw, "%s\t%s\t%s\n", "ID", "Name", "Link")
fmt.Fprintf(tw, "%s\t%s\t%s\n", ui.Bold("ID"), ui.Bold("Name"), ui.Bold("Link"))
for _, campaign := range campaigns.Results {
fmt.Fprintf(tw, "%s\t%s\t%v\n", campaign.ID, campaign.Name, campaign.SignupLink)
fmt.Fprintf(tw, "%s\t%s\t%v\n", ui.Dim(campaign.ID), campaign.Name, ui.Highlight(campaign.SignupLink))
}

_ = tw.Flush()

fmt.Fprintf(w, "\n%s\n", ui.RenderRecordCounter(len(campaigns.Results), campaigns.Meta.Count))
fmt.Fprintf(w, "\n%s\n", ui.Dim(ui.RenderRecordCounter(len(campaigns.Results), campaigns.Meta.Count)))

return nil
}
3 changes: 1 addition & 2 deletions cmd/campaign/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -107,7 +106,7 @@ func TestNewListCommandHandlesErrors(t *testing.T) {
_ = cmd.Flags().Set("workspace", "991199")
err := cmd.RunE(cmd, nil)

expected := fmt.Sprintf("error: %s", errorMessage)
expected := errorMessage

if err.Error() != expected {
t.Fatalf("expected\n'%s'\ngot\n'%s'\n", expected, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion cmd/filters/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ There are two types of filters:
RunE: func(cmd *cobra.Command, args []string) error {
err := renderList(client)
if err != nil {
return fmt.Errorf("error: %s", err.Error())
return err
}

return nil
Expand Down
Loading
Loading