farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
17 stars 13 forks source link

Taxonomy term test failing with 404 #43

Closed jgaehring closed 3 years ago

jgaehring commented 3 years ago

Got a weird result from the GitHub Actions test run last night, which passed on my local machine:

  28 passing (14s)
  1 failing

  1) term
       creates a term with client-generated id, revises, fetches and deletes it.:
     Error: Request failed with status code 404
      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at settle (node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:269:11)
      at endReadableNT (internal/streams/readable.js:1317:12)
      at processTicksAndRejections (internal/process/task_queues.js:82:21)

I'm wondering if there have been any changes that might effect terms since I last updated my local 2.x server?

mstenta commented 3 years ago

Huh - 404 is weird. What path is it trying to make the request(s) to?

jgaehring commented 3 years ago

Well, there are 3 main requests, but I'm not sure which one failed:

The only thing that leaps out to me is the query param on the second one has some spaces that haven't been encoded, but those strings are taken from the raw config passed to axios, which should still get encoded before it finally goes out.

In fact, checking my terminal where I have the farmOS container running, I can see that request with proper encoding:

www_1 | 172.21.0.1 - - [29/Sep/2021:15:34:24 +0000] "GET /api/taxonomy_term/material?filter[name-0-filter][condition][path]=name&filter[name-0-filter][condition][operator]=%3D&filter[name-0-filter][condition][value]=Node%20Test%20Revised HTTP/1.1" 200 2560 "-" "axios/0.21.2"

Here's a full dump from my local run:

{
  "responses": [
    {
      "status": 201,
      "statusText": "Created",
      "headers": {
        "date": "Wed, 29 Sep 2021 15:34:24 GMT",
        "server": "Apache/2.4.38 (Debian)",
        "x-powered-by": "PHP/7.4.21",
        "cache-control": "must-revalidate, no-cache, private",
        "location": "http://localhost/api/taxonomy_term/material/4101ad86-03f6-45a1-93d5-88a7ff096170",
        "x-ua-compatible": "IE=edge",
        "content-language": "en",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "expires": "Sun, 19 Nov 1978 05:00:00 GMT",
        "x-generator": "Drupal 9 (https://www.drupal.org)",
        "content-length": "1907",
        "connection": "close",
        "content-type": "application/vnd.api+json"
      },
      "config": {
        "url": "api/taxonomy_term/material",
        "method": "post",
        "data": "{\"data\":{\"id\":\"4101ad86-03f6-45a1-93d5-88a7ff096170\",\"type\":\"taxonomy_term--material\",\"attributes\":{\"name\":\"Node Test\"}}}",
        "headers": {
          "Accept": "application/vnd.api+json",
          "Content-Type": "application/vnd.api+json",
          "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImI5MjdiZDgzZGU5ZjQ0Yjk1YWRlZDIxN2MxYzlmNWEyNjFiZTg0OWE1MzkyMDQ3NjU1ZWQ5NzBkMjdkZWE2MjAwODc1NDdjYzNkM2M2YjBiIn0.eyJhdWQiOiI2YmYwZDhiZC01ZTMyLTRmMTMtOGM2MS1hYmFkNzBhYjE5MTIiLCJqdGkiOiJiOTI3YmQ4M2RlOWY0NGI5NWFkZWQyMTdjMWM5ZjVhMjYxYmU4NDlhNTM5MjA0NzY1NWVkOTcwZDI3ZGVhNjIwMDg3NTQ3Y2MzZDNjNmIwYiIsImlhdCI6MTYzMjkyOTY2NCwibmJmIjoxNjMyOTI5NjY0LCJleHAiOjE2MzI5MzMyNjQsInN1YiI6IjEiLCJzY29wZXMiOlsiYXV0aGVudGljYXRlZCJdfQ.RyOlycyF3asJahLQNliZSp-n172_l453YWqlkrowE31cNHxkZxKq4V1R1g04eQqaeRrVXzlTgNEn5Q0lTn-dOxrc7F1MMM6yZSWP5J-DRL5kD-_h5w0xwDBFrjR0bAsq7NvHwWCqzOEONnw1R6JWRa4qPdK6yglJv0l0QhKpPaIr8tigN-A9a9brFgW5At1hrdMFhtfr0dJ_aaOlUOD9mkZL4GH4NPbsaXb_T6jA77KyGlFqfA8JshsQipt5bRF0Ec_CXbALwOHSou4IY_I5KswH63aTRxJNCLr8C87bYvrLbVwl3mh34cv9pgwoztiBnkrozWYpsc_pZEjraNWaD2ytAKtYWCKkvdyfN9hULLG3Oit-d1cuwPy29ZOkzx2ebVzIVcP9_dYJ_rxX0czZWD7tyO-P__5Guzh2FLim9f6n8yGvV4au6Uf6QgEBXQ3eIbIDvDv_x7MI6DxCBMzoQWwxuvS3n7auHwd1abtMfug_Rd9fBOVO7gTz2-D2gq6_zed2zpCILoKFlXCJExT1qyyLJmdN_Q_anGJmUdfMe_VECtArfr6dL42nbFKMl4vhpsQZzc0Zgbl8K3N1-VHmqPcgnNYTCsqMhrsh5YJcTcg-8yPf9RLNLzySPboKkMMxeg0RazEWZ32H5Lm7GHxbn139-_vzMa9F9fHQ4HbSnc8",
          "User-Agent": "axios/0.21.2",
          "Content-Length": 121
        },
        "baseURL": "http://localhost",
        "transformRequest": [
          null
        ],
        "transformResponse": [
          null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "transitional": {
          "silentJSONParsing": true,
          "forcedJSONParsing": true,
          "clarifyTimeoutError": false
        }
      }
    },
    {
      "status": 200,
      "statusText": "OK",
      "headers": {
        "date": "Wed, 29 Sep 2021 15:34:24 GMT",
        "server": "Apache/2.4.38 (Debian)",
        "x-powered-by": "PHP/7.4.21",
        "cache-control": "must-revalidate, no-cache, private",
        "x-ua-compatible": "IE=edge",
        "content-language": "en",
        "x-content-type-options": "nosniff",
        "x-frame-options": "SAMEORIGIN",
        "expires": "Sun, 19 Nov 1978 05:00:00 GMT",
        "x-generator": "Drupal 9 (https://www.drupal.org)",
        "content-length": "2116",
        "connection": "close",
        "content-type": "application/vnd.api+json"
      },
      "config": {
        "url": "api/taxonomy_term/material?filter[name-0-filter][condition][path]=name&filter[name-0-filter][condition][operator]=%3D&filter[name-0-filter][condition][value]=Node Test Revised",
        "method": "get",
        "data": "{}",
        "headers": {
          "Accept": "application/vnd.api+json",
          "Content-Type": "application/vnd.api+json",
          "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJ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NLzySPboKkMMxeg0RazEWZ32H5Lm7GHxbn139-_vzMa9F9fHQ4HbSnc8",
          "User-Agent": "axios/0.21.2",
          "Content-Length": 2
        },
        "baseURL": "http://localhost",
        "transformRequest": [
          null
        ],
        "transformResponse": [
          null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "transitional": {
          "silentJSONParsing": true,
          "forcedJSONParsing": true,
          "clarifyTimeoutError": false
        }
      }
    },
    {
      "status": 200,
      "statusText": "OK",
      "headers": "[Circular: headers]",
      "config": {
        "url": "api/taxonomy_term/material?filter[id-0-filter][condition][path]=id&filter[id-0-filter][condition][operator]=%3D&filter[id-0-filter][condition][value]=4101ad86-03f6-45a1-93d5-88a7ff096170",
        "method": "get",
        "data": "{}",
        "headers": "[Circular: headers]",
        "baseURL": "http://localhost",
        "transformRequest": [
          null
        ],
        "transformResponse": [
          null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "transitional": {
          "silentJSONParsing": true,
          "forcedJSONParsing": true,
          "clarifyTimeoutError": false
        }
      }
    }
  ],
  "errors": []
}
jgaehring commented 3 years ago

Here's a full dump from my local run

Actually, I did truncate it a bit to remove some of the noisy internal properties from axios.

On that subject, I'm using an ad hoc reporting function to dump those responses into a JSON file. Do you know, @mstenta, if there's a good way to retrieve a file created during a GitHub Action?

paul121 commented 3 years ago

Aha! We renamed the material taxonomy to material_type: https://github.com/farmOS/farmOS/commit/b88877b61706ded3590f71b23bac48041c9470ac

mstenta commented 3 years ago

Aha! We renamed the material taxonomy to material_type: farmOS/farmOS@b88877b

AHHH haha forgot! That'd do it. :-P

jgaehring commented 3 years ago

Aha! Good catch, @paul121! Guess I'll need to update my local!

mstenta commented 3 years ago

Do you know, @mstenta, if there's a good way to retrieve a file created during a GitHub Action?

Yes! There's a way to create artifacts that you can download after the run. I used it once, but it was a while ago.

https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts

paul121 commented 3 years ago

Also https://github.com/actions/upload-artifact

jgaehring commented 3 years ago

Oh great, I'll check those out.

I also just found this: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging

Maybe for now I'll just write something up that dumps some JSON from any errors that halt a test from running. Could be helpful for issues like this that happen in the future, where it's not the test per se that fails, but rather compatibility issue.

jgaehring commented 3 years ago

I opened jgaehring#4 to see if replacing material with material_type would work, which it did. In the course of things, I wound up tweaking the GH Action workflow a bit, too. I'm probably going to hold off on merging that PR so I can keep moving quickly in my dev environment w/o updating my local server. But I feel confident I can close this for now.

jgaehring commented 3 years ago

Reopening this for now, just so I remember to revert e9f562a.

jgaehring commented 3 years ago

Reopening this for now, just so I remember to revert e9f562a.

Scratch that, decided to go ahead with merging jgaehring/farmOS.js#4 right now and just keep commit e9f562a on my local machine and drop it from any major branches I push up to GH.