Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeDictItems cannot overwrite #27

Closed
trieloff opened this issue Jan 22, 2019 · 2 comments · Fixed by #28
Closed

writeDictItems cannot overwrite #27

trieloff opened this issue Jan 22, 2019 · 2 comments · Fixed by #28
Labels
bug Something isn't working released

Comments

@trieloff
Copy link

Trace: { Error: Duplicate dictionary_item: 'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2'
    at request.then (/code/helix-publish/node_modules/@adobe/fastly-native-promises/src/httpclient.js:32:17)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  data:
   { msg: 'Duplicate record',
     detail: 'Duplicate dictionary_item: \'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2\'' },
  status: 409,
  code: 'Duplicate record' }
    at Promise.all.then.catch (/code/helix-publish/src/publish.js:48:13)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
{ Error: Duplicate dictionary_item: 'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2'
    at request.then (/code/helix-publish/node_modules/@adobe/fastly-native-promises/src/httpclient.js:32:17)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  data:
   { msg: 'Duplicate record',
     detail: 'Duplicate dictionary_item: \'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2\'' },
  status: 409,
  code: 'Duplicate record' }
{ statusCode: 500,
  body:
   { status: 'Error',
     error: 'Error: Duplicate dictionary_item: \'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2\'',
     stack:
      [ 'Error: Duplicate dictionary_item: \'dictionary_id=3aT1oK0tdPlNo48E8TnhVx item_key=default service_id=6E6ge7REhiWetPCqy9jht2\'',
        '    at request.then (/code/helix-publish/node_modules/@adobe/fastly-native-promises/src/httpclient.js:32:17)',
        '    at <anonymous>',
        '    at process._tickCallback (internal/process/next_tick.js:188:7)' ] } }
@trieloff trieloff added the bug Something isn't working label Jan 22, 2019
@trieloff
Copy link
Author

The underlying issue is that the dictionary is write_only:

GET https://api.fastly.com/service/6E6ge7REhiWetPCqy9jht2/version/26/dictionary/strain_deny

HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json
Cache-Control: no-cache
Accept-Ranges: bytes
Via: 1.1 varnish
Content-Length: 211
Accept-Ranges: bytes
Date: Tue, 22 Jan 2019 10:10:49 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-control-slwdc9035-CONTROL-SLWDC, cache-hhn1546-HHN
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1548151849.924595,VS0,VE489
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000

{"version":26,"name":"strain_deny","deleted_at":null,"service_id":"6E6ge7REhiWetPCqy9jht2","created_at":"2019-01-22T09:46:25Z","write_only":true,"updated_at":"2019-01-22T09:46:25Z","id":"6YKIcQLobbr3ZNJXd6Wr0p"}

and then:

GET https://api.fastly.com/service/6E6ge7REhiWetPCqy9jht2/dictionary/6YKIcQLobbr3ZNJXd6Wr0p/item/default

HTTP/1.1 400 Bad Request
Status: 400 Bad Request
Content-Type: application/json
Cache-Control: no-cache
Accept-Ranges: bytes
Via: 1.1 varnish
Accept-Ranges: bytes
Content-Length: 86
Accept-Ranges: bytes
Date: Tue, 22 Jan 2019 10:10:50 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-control-slwdc9037-CONTROL-SLWDC, cache-hhn1521-HHN
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1548151850.553670,VS0,VE469
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000

{"msg":"Bad request","detail":"Not allowed to read contents of write_only dictionary"}

Therefore:

POST https://api.fastly.com/service/6E6ge7REhiWetPCqy9jht2/dictionary/01zrr2NLhDsfCDwg02J3nY/item

HTTP/1.1 409 Conflict
Status: 409 Conflict
Content-Type: application/json
Cache-Control: no-cache
Fastly-RateLimit-Remaining: 867
Fastly-RateLimit-Reset: 1548154800
Accept-Ranges: bytes
Via: 1.1 varnish
Content-Length: 154
Accept-Ranges: bytes
Date: Tue, 22 Jan 2019 10:10:50 GMT
Via: 1.1 varnish
Connection: keep-alive
X-Served-By: cache-control-slwdc9036-CONTROL-SLWDC, cache-hhn1547-HHN
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1548151850.902627,VS0,VE494
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000

{"msg":"Duplicate record","detail":"Duplicate dictionary_item: 'dictionary_id=01zrr2NLhDsfCDwg02J3nY item_key=default service_id=6E6ge7REhiWetPCqy9jht2'"}

trieloff added a commit that referenced this issue Jan 22, 2019
Getting the value of an edge dictionary value for a write-only dictionary results in an error 400
from the Fastly API, which is correct, but not helpful. Because `readDictItem` always gets the
dictionary metadata before reading, we can guard against this error and return a proper response
(status: 403, item_value: undefined)

fixes #27
trieloff pushed a commit that referenced this issue Jan 22, 2019
## [1.3.2](v1.3.1...v1.3.2) (2019-01-22)

### Bug Fixes

* **fastly:** Return undefined for dict values of write-only edge dicts ([ab5972a](ab5972a)), closes [#27](#27)
@trieloff
Copy link
Author

🎉 This issue has been resolved in version 1.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant