basecradle 0.14.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e24738f465459e941778b070a1ffc7efa17706bf50394d390eb0e79956ced97a
4
- data.tar.gz: a6ff325d3f9982308e095d8301f84be8c6684f74fb979529b1a054277da49004
3
+ metadata.gz: e2f24c012adffce3eb5bf812fd4fe41244e33a255f63a7b6c4c751e919d77740
4
+ data.tar.gz: ba6c3c758aa25b0d744c8dcf5362cfa754de9e32f7a6fcdbdad5ed749afe643d
5
5
  SHA512:
6
- metadata.gz: fcc928a5d0316b25def0963fcc20aec41e298d2a3a249f8fb45e8b0b56715496793a629fbdb895c84f24f322d231734c6a2b8824b73235fab547982e19755434
7
- data.tar.gz: cb8dcf49330a18e7e05851a62e802d35fd21d975ff15947b96c0ec909013b4087ff92ce9a7978f09b14e90e64eefb02b9d6785415054586c9e219eb3a1c4f5ce
6
+ metadata.gz: 53023dc5e3c3c2cfca97302f7c158859945e526649f986e90b598f73a83ed87ad6d3c5851c014c8302a01c4dbe56be90940f746a931b2103633deaf4595e0f58
7
+ data.tar.gz: 3013c477c9c3e10c0a3a5a7accf7a462f45c006e1d2b204344cd8727201f6cae2056451595cce61509c33b7efdd4f5c78ebfc683990ed53013d631e679d3fe02
data/CHANGELOG.md CHANGED
@@ -9,6 +9,27 @@ section**. The newest heading is always the version `lib/basecradle/version.rb`
9
9
  a release writes its entry and its version in the same PR — and `test/changelog_test.rb`
10
10
  fails CI if the two ever disagree.
11
11
 
12
+ ## [0.14.2] - 2026-11-16
13
+
14
+ A patch release with one behavior fix. No verb is added or removed, and no signature
15
+ changes. The one caller it affects passes an `idempotency_key` made only of whitespace:
16
+ that create is now sent without a key and is no longer auto-retried.
17
+
18
+ ### Fixed
19
+
20
+ - **A whitespace-only `idempotency_key` is no key**
21
+ ([#292](https://github.com/basecradle/basecradle-ruby/pull/292),
22
+ [#288](https://github.com/basecradle/basecradle-ruby/issues/288)). A key made only of
23
+ whitespace (`" "`, `"\t"`) used to go out as an `Idempotency-Key` header. A client built
24
+ with `max_retries:` would also re-send that create after a lost connection. The platform
25
+ reads a blank header as no key, so it could not deduplicate that create, and a retry
26
+ could post a duplicate. A key that is `nil`, empty, or only spaces, tabs and line breaks
27
+ now counts as no key on `timeline.messages.create`, `timeline.assets.create`,
28
+ `timeline.tasks.create` and `timeline.webhook_endpoints.create`: no header is sent, and
29
+ the create is never auto-retried. Use a fresh UUID per logical create. The Python SDK
30
+ is making the same change
31
+ ([basecradle-python#349](https://github.com/basecradle/basecradle-python/issues/349)).
32
+
12
33
  ## [0.14.1] - 2026-11-16
13
34
 
14
35
  A patch release. It carries one behavior fix brought over from the Python SDK and a
@@ -773,6 +794,7 @@ the Python SDK's behavior in idiomatic Ruby. Zero runtime dependencies.
773
794
  - **Quality bars** — a README-as-tested-doc harness (every example runs against a mocked
774
795
  API) and a spec drift-guard (CI fails if the live API grows beyond the SDK).
775
796
 
797
+ [0.14.2]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.2
776
798
  [0.14.1]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.1
777
799
  [0.14.0]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.14.0
778
800
  [0.13.0]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.13.0
data/README.md CHANGED
@@ -254,7 +254,7 @@ the same way. What gives the folding up is converting away from the type: both
254
254
 
255
255
  ## Idempotent creates & safe retries
256
256
 
257
- A create can succeed on the server while its response is lost on the wire — retrying it blind would duplicate the record. Pass an `idempotency_key:` (a UUID is ideal; any string works) and the platform stores **at most one record per key**: a resend returns the *original* record — no duplicate message, asset, task activation, or webhook endpoint. All four create methods accept it.
257
+ A create can succeed on the server while its response is lost on the wire — retrying it blind would duplicate the record. Pass an `idempotency_key:` (a UUID is ideal; any non-blank string works — an empty or whitespace-only key counts as no key) and the platform stores **at most one record per key**: a resend returns the *original* record — no duplicate message, asset, task activation, or webhook endpoint. All four create methods accept it.
258
258
 
259
259
  Keys are scoped **per timeline and per author** for all four resources — yours never collide with another peer's, and the same key on two timelines creates two records.
260
260
 
@@ -16,12 +16,21 @@ module BaseCradle
16
16
  data["uuid"] || data.fetch("content")["uuid"]
17
17
  end
18
18
 
19
+ # A key the platform cannot deduplicate on is no key at all: +nil+, an empty string, or
20
+ # a string of only whitespace — the platform reads the header with Rails' +presence+,
21
+ # which takes a blank value for none. Both places that read a key (the header a create
22
+ # sends, and whether a request may be retried) ask this one question (#288). +scrub+
23
+ # keeps a key with invalid bytes a key, rather than raising out of +strip+.
24
+ def self.blank_idempotency_key?(key)
25
+ key.to_s.scrub.strip.empty?
26
+ end
27
+
19
28
  # The per-request headers carrying an optional idempotency key — +nil+ when no key was
20
29
  # given (so a create without a key sends no +Idempotency-Key+ header, and is never
21
- # auto-retried). An empty string is no key, the same as +nil+. Shared by the four
30
+ # auto-retried). A blank key is no key, the same as +nil+. Shared by the four
22
31
  # content-create methods.
23
32
  def self.idempotency_headers(key)
24
- key.to_s.empty? ? nil : { "Idempotency-Key" => key }
33
+ blank_idempotency_key?(key) ? nil : { "Idempotency-Key" => key }
25
34
  end
26
35
 
27
36
  # A read-only, wire-exact view of one API JSON object.
@@ -76,8 +76,8 @@ module BaseCradle
76
76
  # off. When set above 0, only requests that are safe to re-send are retried: any +GET+
77
77
  # (reads change nothing) and any create carrying an +idempotency_key+ (the platform
78
78
  # dedupes keyed creates, so a resend can't duplicate the record). An unkeyed +POST+ is
79
- # never retried, whatever this is set to. Retries back off exponentially, capped at
80
- # RETRY_MAX_DELAY seconds.
79
+ # never retried, whatever this is set to — and a blank key (empty, or only whitespace)
80
+ # is no key. Retries back off exponentially, capped at RETRY_MAX_DELAY seconds.
81
81
  def initialize(token = nil, base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT,
82
82
  max_retries: DEFAULT_MAX_RETRIES)
83
83
  resolved = token || ENV.fetch("BASECRADLE_TOKEN", nil)
@@ -323,12 +323,12 @@ module BaseCradle
323
323
 
324
324
  # A request is safe to auto-retry only when re-sending it can't create a duplicate: a
325
325
  # +GET+ (reads change nothing), or any request carrying an +Idempotency-Key+ (the
326
- # platform dedupes keyed creates). An unkeyed write is never retried.
326
+ # platform dedupes keyed creates). An unkeyed write is never retried, and a blank key
327
+ # (empty or only whitespace) is no key: the platform cannot dedupe on it.
327
328
  def retryable?(method, http_request)
328
329
  return true if method.to_s.upcase == "GET"
329
330
 
330
- key = http_request["Idempotency-Key"]
331
- !(key.nil? || key.empty?)
331
+ !BaseCradle.blank_idempotency_key?(http_request["Idempotency-Key"])
332
332
  end
333
333
 
334
334
  # Build and send an authenticated request; returns the raw Net::HTTPResponse, whatever
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BaseCradle
4
- VERSION = "0.14.1"
4
+ VERSION = "0.14.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drawk Kwast