Hello. While adding a new feature via an API call...
# ask-questions
n
Hello. While adding a new feature via an API call I noticed that tags I assign are not applied. Anyone came across this issue, and maybe has a workaround/or I'm missing something please? I did try creating the tag via the UI Settings->Tags before hand as well but same behaviour. POST /api/v1/features. with the below body
Copy code
{
  "id": "dark-mode4",
  "description": "Dark mode",
  "archived": false,
  "owner": "test-app",
  "project": "prj_40645322lyfvtzsz",
  "valueType": "boolean",
  "defaultValue": "false",
  "tags": [
    "Active"
  ]
}
r
Hi Reuben, what API response do you get when you make that POST request? Are you able to add the tag to the feature manually in the GrowthBook dashboard after creating the feature with the API, or is that not working either?
n
Hi August, The response is the following i.e. it succeeds but the tags array in the response is empty. I am able to add the tag manually via the GrowthBook Dashboard. Also once I do this I can fetch the feature via API and in this case the response would show me the tag I added manually via the UI. Below is the response I get when creating the feature tag via the API call ... note the empty tags array
Copy code
{
  "feature": {
    "id": "dark-mode4",
    "description": "Dark mode",
    "archived": false,
    "dateCreated": "2024-07-10T14:21:02.969Z",
    "dateUpdated": "2024-07-10T14:21:02.969Z",
    "defaultValue": "false",
    "environments": {
      "production": {
        "enabled": false,
        "defaultValue": "false",
        "rules": []
      },
      "pre-production": {
        "enabled": false,
        "defaultValue": "false",
        "rules": []
      },
      "qa": {
        "enabled": false,
        "defaultValue": "false",
        "rules": []
      },
      "qa-perf": {
        "enabled": false,
        "defaultValue": "false",
        "rules": []
      }
    },
    "owner": "test-app",
    "project": "prj_40645322lyfvtzsz",
    "tags": [],
    "valueType": "boolean",
    "revision": {
      "comment": "",
      "date": "2024-07-10T14:21:02.969Z",
      "publishedBy": "",
      "version": 1
    }
  }
}
In terms of docker images I am using: mongo:latest and growthbook/growthbook:latest
I do have a workaround however. If after creating a new toggle, I updated it passing in the tag via API, the tag gets applied. Ideally I avoid two calls so the create and tag is atomic, but short term can work around to keep on assessing the product fit
r
Hi Reuben, thanks very much for providing me with the extra details. I completely agree with you that it would be better to not have to make 2 API calls. I will ask someone on our Engineering team to take a look at this and I'll send an update here in the thread once I have one. Thanks again!
I had a moment so I took a look at this myself. It appears that we may not be detecting the "tags" at all for the POST request for that endpoint. The associated file doesn't have any reference to tags: https://github.com/growthbook/growthbook/blob/main/packages/back-end/src/api/features/postFeature.ts It should be happening somewhere in here: https://github.com/growthbook/growthbook/blob/3fe6181d3c0ff6411348c428d1fa05d6545ce845/packages/back-end/src/api/features/postFeature.ts#L86-L112 I was about to create a GitHub issue for this but I see you already did! Thank you so much. I'll add this info to it. :-D
n
Splendid, also saw the issue has been fixed - will retest with the changes. Thanks for looking into this.