Skip to content

River Args Uniqueness Not Working #1075

@assembly-deepali

Description

@assembly-deepali

I have these two payloads that I'm passing into river, and because of my custom uniqueness constraints, I don't want to be adding both of them in. But it still is, am I missing something?

Followed this format: https://pkg.go.dev/github.com/riverqueue/river#example-package-UniqueJob and am using https://riverqueue.com/docs/unique-jobs (custom unique job args)

type SyncPayload struct {
	ParentPayload
	SyncName        string `json:"syncName" river:"unique"`
	Model           string `json:"model"`
	ResponseResults struct {
		Added   int `json:"added"`
		Updated int `json:"updated"`
		Deleted int `json:"deleted"`
	} `json:"responseResults"`
	SyncType      nango.SyncType `json:"syncType" river:"unique"`
	ModifiedAfter string         `json:"modifiedAfter"`
}

type NangoSyncArgs struct {
	OrgID       string      `json:"org_id" river:"unique"`
	Payload     SyncPayload `json:"payload"`
	SlackTeamId string      `json:"slack_team_id"`
	NextCursor  *string     `json:"next_cursor,omitempty" river:"unique"`
}

// Kind implements river.JobArgs.
func (NangoSyncArgs) Kind() string {
	return "NangoSyncArgs"
}

func (a NangoSyncArgs) InsertOpts() river.InsertOpts {
	return river.InsertOpts{
		MaxAttempts: 5,
		Tags:        []string{fmt.Sprintf("org_id: %s", a.OrgID)},
		Queue:       GetCorrectCRMSyncWorkerQueue(a.Payload.SyncType == nango.InitialSync),
		UniqueOpts:  river.UniqueOpts{ByArgs: true},
	}
}
{
  "org_id": "1",
  "payload": {
    "from": "nango",
    "type": "sync",
    "model": "Account",
    "syncName": "accounts",
    "syncType": "INCREMENTAL",
    "connectionId": "a",
    "modifiedAfter": "2025-11-11T22:15:04.779Z",
    "responseResults": {
      "added": 0,
      "deleted": 0,
      "updated": 1
    },
    "providerConfigKey": "salesforce"
  },
  "next_cursor": "matching cursor",
  "slack_team_id": "a"
}

{
  "org_id": "1",
  "payload": {
    "from": "nango",
    "type": "sync",
    "model": "Account",
    "syncName": "accounts",
    "syncType": "INCREMENTAL",
    "connectionId": "a",
    "modifiedAfter": "2025-11-12T02:50:04.953Z",
    "responseResults": {
      "added": 0,
      "deleted": 0,
      "updated": 5
    },
    "providerConfigKey": "salesforce"
  },
  "next_cursor": "matching cursor",
  "slack_team_id": "a"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions