confeature 0.1.0 → 0.1.1

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: 5c74197f202ea8a52c598c91b8bfb70dcc101c7a63d48404f3b2d48d1b38a64d
4
- data.tar.gz: 62f38b52d867749b78a3db84e9d9da13c5d3ff4be37199a2b50fba0907198468
3
+ metadata.gz: 526cadeccff8c73783cedea06b2913852c5d3dc1def25e1849226acc810ff7c8
4
+ data.tar.gz: e4d743d9078e1d9bdf06b4a758938dee26e62a147c5121abf08dde83833db062
5
5
  SHA512:
6
- metadata.gz: 5ee1fff4f6e74c8a305f00d33622b899f8f1bd6495589f95455e92ad8014a71de0ab8d590edc0742aab3ec563076ad8b523614d106f5f315709434c048bb9c0e
7
- data.tar.gz: ee1a650aa4f1a0837b6187213796d972f6b18459d019645859f80a613be9a20940525ac012725e098fbe57e35e4174b45ec9dfa2a17c2aa2037e90c0ccd2aa79
6
+ metadata.gz: 6524aa693004bb6459f5a87a2524a295b7a4c100e05a8d420570e01fa6b2853c586ca3bc2534f7216fb046a5cfa3778fc83e6ef6fe09625bc5ad3921d77eca35
7
+ data.tar.gz: 2474b277f34cdeffe9554153ac44e72bf94c92b9816ce18bddb0d31e8644d6cd6c00a8dc8ea22e722de3f11e526164fd5e2a40baf5c4f3e2644a8ff5f564f863
@@ -32,7 +32,7 @@ module Confeature
32
32
  # So no exception text is ever passed on (it may quote the URL): only
33
33
  # the exception's class picks a fixed reason code.
34
34
  class ConfigFetcher
35
- DEFAULT_BASE_URL = "https://cdn-global.confeature.io"
35
+ DEFAULT_BASE_URL = "https://cdn.confeature.io"
36
36
 
37
37
  # Reason code when the key cannot be placed in a path segment
38
38
  # ("", "." or "..") — the fetcher refuses to fetch (#803 FR-001).
@@ -42,6 +42,10 @@ module Confeature
42
42
  # URL — no request is made (#803 FR-002; sdk-go's code).
43
43
  INVALID_REQUEST = "invalid_request"
44
44
 
45
+ # Reason code of a dropped connection: a transport exception, or a
46
+ # 2xx body cut short of its Content-Length (#920).
47
+ CONNECTION_RESET = "connection_reset"
48
+
45
49
  # Transport failures -> fixed, key-free reason codes (#803 FR-002;
46
50
  # mirrors sdk-go's `classifyError`). Order matters: a timeout is
47
51
  # checked first (`Net::OpenTimeout` etc. descend from
@@ -109,7 +113,7 @@ module Confeature
109
113
  # reason code (#803 FR-002). The message is never read.
110
114
  def self.classify_error(exc)
111
115
  return "timeout" if TIMEOUT_ERRORS.any? { |klass| exc.is_a?(klass) }
112
- return "connection_reset" if CONNECTION_RESET_ERRORS.any? { |klass| exc.is_a?(klass) }
116
+ return CONNECTION_RESET if CONNECTION_RESET_ERRORS.any? { |klass| exc.is_a?(klass) }
113
117
 
114
118
  "network_error"
115
119
  end
@@ -166,6 +170,11 @@ module Confeature
166
170
  http.open_timeout = @timeout
167
171
  http.read_timeout = @timeout
168
172
  http.write_timeout = @timeout if http.respond_to?(:write_timeout=)
173
+ # Net::HTTP silently retries an idempotent GET once on a read
174
+ # timeout or a reset (`max_retries` defaults to 1): two requests,
175
+ # and twice the deadline, for one fetch. One fetch is one request —
176
+ # the poll service owns retrying (#920, found by the live suite).
177
+ http.max_retries = 0
169
178
  http
170
179
  end
171
180
 
@@ -183,6 +192,8 @@ module Confeature
183
192
  when Net::HTTPNotModified
184
193
  FetchResult.new(status: :not_modified, etag: response["etag"])
185
194
  when Net::HTTPSuccess
195
+ return fail_with(CONNECTION_RESET) if truncated?(response)
196
+
186
197
  parse_success(response)
187
198
  else
188
199
  reason = "HTTP #{response.code}"
@@ -193,6 +204,19 @@ module Confeature
193
204
  end
194
205
  end
195
206
 
207
+ # Net::HTTP reads a Content-Length body ignoring EOF, so a connection
208
+ # dropped mid-body yields a SHORT body, never an EOFError. Without
209
+ # this check it would be misread as malformed JSON — a transport
210
+ # failure reported as CDN drift (wire-cases `network-reset`, #920).
211
+ # Net::HTTP rewrites Content-Length to the inflated size when it
212
+ # decodes gzip, so the comparison holds for a compressed response.
213
+ def truncated?(response)
214
+ declared = response["content-length"]
215
+ return false unless declared&.match?(/\A\d+\z/)
216
+
217
+ response.body.to_s.bytesize < Integer(declared, 10)
218
+ end
219
+
196
220
  def parse_success(response)
197
221
  body = JSON.parse(response.body)
198
222
  unless body.is_a?(Hash)
@@ -7,5 +7,5 @@ module Confeature
7
7
  # `version` field on the gemspec. The major version tracks the
8
8
  # Confeature API contract major version this SDK implements
9
9
  # (Constitution Principle VI).
10
- VERSION = "0.1.0"
10
+ VERSION = "0.1.1"
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confeature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MakerLabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-16 00:00:00.000000000 Z
11
+ date: 2026-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64