diff --git a/CHANGELOG.md b/CHANGELOG.md index 723f62a..76a2174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Send the required `scope: by_schedule_ids` in Forward `schedules().archiveMany(...)`. Earlier releases sent only `schedule_ids`, so every batch archive request was rejected with HTTP 400 `invalid_request`; existing calls work without code changes. + ## [0.3.0] ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3addee3..80e1606 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ Environment/File use page/next_page pagination; retain explicit forward/backward Skill multipart uses repeated files parts and relative filenames. Skill ZIP downloads are direct authenticated streams, not File download grants. Credential updates must enforce zero retries regardless of request overrides; test both status and connection failures. Preserve write-only secret handling, metadata merge-patch nulls, and the distinction between create/update/response auth models. -Schedule batch archive sends only schedule_ids (1–50 unique nonempty IDs); do not copy the older TS scope field. Keep request trigger policy fields separate from computed response fields, preserve merge-patch omission/null distinctions and Batch decimal credits. Batch task cursors use custom IDs; output/error grants are not generic File IDs. Examples must preserve pending inputs and never print signed URLs. +Schedule batch archive always sends `scope: by_schedule_ids` with schedule_ids (1–50 unique nonempty IDs); the server rejects a missing scope. Keep request trigger policy fields separate from computed response fields, preserve merge-patch omission/null distinctions and Batch decimal credits. Batch task cursors use custom IDs; output/error grants are not generic File IDs. Examples must preserve pending inputs and never print signed URLs. Channel QR authorization and message-scope Pairing are different flows. Keep request-only IM credentials separate from redacted response configuration, and never print QR payloads/session keys or pairing codes. Channel tests must not send real IM messages; live QR/pairing acceptance needs a dedicated authorized connection. Preserve fixed/pairing required-field rules and the current code-or-Pairing-ID selector. diff --git a/docs/schedules-batches.md b/docs/schedules-batches.md index 0a97fd1..6272aae 100644 --- a/docs/schedules-batches.md +++ b/docs/schedules-batches.md @@ -52,7 +52,7 @@ ScheduleArchiveManyResponse result = client.schedules().archiveMany( RequestOptions.builder().idempotencyKey(archiveKey).build()); ``` -The request contains **only `schedule_ids`**. The builder snapshots and deduplicates IDs in insertion order and requires 1–50 unique, nonempty IDs. The current official contract rejects `scope` and other extra fields. This differs from the older TypeScript baseline's `scope: by_schedule_ids` implementation; Java follows the current contract. The endpoint permits PAT or administrator SAT; an Identity-bound SAT cannot perform this administrator operation. SDK does not infer permissions from token text. +The SDK sends the required `scope: by_schedule_ids` together with `schedule_ids`; it is the only supported scope and has no server default. The builder snapshots and deduplicates IDs in insertion order and requires 1–50 unique, nonempty IDs. Other extra fields are rejected. The endpoint permits PAT or administrator SAT; an Identity-bound SAT cannot perform this administrator operation. SDK does not infer permissions from token text. ## Batch creation and inspection diff --git a/src/main/java/com/qoder/cloudagents/forward/ScheduleArchiveManyParams.java b/src/main/java/com/qoder/cloudagents/forward/ScheduleArchiveManyParams.java index 356e7ca..7394711 100644 --- a/src/main/java/com/qoder/cloudagents/forward/ScheduleArchiveManyParams.java +++ b/src/main/java/com/qoder/cloudagents/forward/ScheduleArchiveManyParams.java @@ -4,8 +4,12 @@ import com.qoder.cloudagents.errors.ConfigurationException; import java.util.*; -/** An explicit, bounded set of Schedule IDs. The server rejects extra fields including scope. */ +/** + * An explicit, bounded set of Schedule IDs. Requests always carry the only supported scope, {@code + * by_schedule_ids}; the server rejects a missing scope and other extra fields. + */ public final class ScheduleArchiveManyParams implements JsonSerializable { + private static final String SCOPE = "by_schedule_ids"; private final List ids; private ScheduleArchiveManyParams(List value) { @@ -26,7 +30,10 @@ public List scheduleIds() { } public JsonValue toJsonValue() { - return JsonValue.of(Collections.singletonMap("schedule_ids", ids)); + Map body = new LinkedHashMap<>(); + body.put("scope", SCOPE); + body.put("schedule_ids", ids); + return JsonValue.of(body); } public static Builder builder() { diff --git a/src/test/java/com/qoder/cloudagents/SchedulesBatchesTest.java b/src/test/java/com/qoder/cloudagents/SchedulesBatchesTest.java index 7a62275..204e6d4 100644 --- a/src/test/java/com/qoder/cloudagents/SchedulesBatchesTest.java +++ b/src/test/java/com/qoder/cloudagents/SchedulesBatchesTest.java @@ -63,7 +63,7 @@ static Stream routes() { "archiveMany", "POST", "/schedules/archive", - "{\"schedule_ids\":[\"sched_1\",\"sched_2\"]}", + "{\"scope\":\"by_schedule_ids\",\"schedule_ids\":[\"sched_1\",\"sched_2\"]}", "{\"archived_count\":2}" }, {"scheduleGet", "GET", "/schedules/id%2F%3F%23%25", "", "{\"id\":\"sched_1\"}"}, @@ -358,7 +358,10 @@ void boundedArchiveAndRequiredParametersFailBeforeSending() { ids.clear(); ScheduleArchiveManyParams p = b.build(); assertEquals(Arrays.asList("s1", "s2"), p.scheduleIds()); - assertEquals(Collections.singleton("schedule_ids"), p.toJsonValue().asObject().keySet()); + assertEquals( + Arrays.asList("scope", "schedule_ids"), + new ArrayList<>(p.toJsonValue().asObject().keySet())); + assertEquals("by_schedule_ids", p.toJsonValue().get("scope").asString()); assertThrows(UnsupportedOperationException.class, () -> p.scheduleIds().clear()); ScheduleSink sink = ScheduleSink.builder().type("im_channel").build(); assertThrows(