openflagr / flagr-archived

[Archived] - Merged and move to https://github.com/openflagr/flagr
https://openflagr.github.io/flagr
Apache License 2.0
33 stars 7 forks source link

PUT /api/v1/flag/$id does not allow editing "flag.enabled" #43

Closed marceloboeira closed 2 years ago

marceloboeira commented 2 years ago

Updating enabled attribute through PUT /api/v1/flag/$id does NOT work.

It does not respect the flagr API definition: https://github.com/openflagr/goflagr/blob/e97f63ad2c236783d4afa2f9f630c2aeb53a042d/model_put_flag_request.go#L12

For instance, creating a flag:

http POST :18000/api/v1/flags Description=Germany
HTTP/1.1 200 OK
Content-Type: application/json

{
    "dataRecordsEnabled": false,
    "description": "Germany",
    "enabled": false,
    "id": 8,
    "key": "kt8kfh38c19uqaeo3",
    "segments": [],
    "tags": [],
    "updatedAt": "2021-10-04T19:52:41.676Z",
    "variants": []
}

Notice the ID is 8 and the flag is disabled...

If one tries to edit enabled:

Expected Behavior

echo "{\"enabled\": true}" | http PUT :18000/api/v1/flags/8
HTTP/1.1 200 OK
Content-Type: application/json

{
    "dataRecordsEnabled": false,
    "description": "Deutschland",
    "enabled": true,
    "id": 8,
    "key": "kt8kfh38c19uqaeo3",
    "segments": [],
    "tags": [],
    "updatedAt": "2021-10-04T19:54:35.206Z",
    "variants": []
}

It doesn't do anything really...

Current Behavior

echo "{\"enabled\": true}" | http PUT :18000/api/v1/flags/8
HTTP/1.1 200 OK
Content-Type: application/json

{
    "dataRecordsEnabled": false,
    "description": "Deutschland",
    "enabled": false,
    "id": 8,
    "key": "kt8kfh38c19uqaeo3",
    "segments": [],
    "tags": [],
    "updatedAt": "2021-10-04T19:54:35.206Z",
    "variants": []
}

Possible Solution

Add the field here, similar to DataRecordsEnabled? https://github.com/openflagr/flagr/blob/f6a8dd233467c793055ece212e9eb05610b9d0c3/pkg/handler/crud.go#L218-L220

Steps to Reproduce (for bugs)

See above

Your Environment

marceloboeira commented 2 years ago

It seems that other fields and methods are also affect

POST doesn't support Enabled, DataRecordsEnabled, Notes, ... PUT doesn't support Enabled

github-actions[bot] commented 2 years ago

Stale issue message