Skip to content

entitlement config db side representation seems off #1187

Open
@linear

Description

@linear

If I create a new entitlement using the dev.openmeter.cloud UI, then I get this record in the database:

-[ RECORD 6 ]--------------+--------------------------------
id                         | 01J2H4RGFEVG5KB7MCRTW942BX
namespace                  | org_2gPE6cSwxa5y1zeXOc60oDA7LBZ
metadata                   | null
created_at                 | 2024-07-11 14:57:05.006715+00
updated_at                 | 2024-07-11 14:57:05.006715+00
deleted_at                 |
feature_id                 | 01J1W8MXX86HFGM4H7DBJ30GJP
subject_key                | testx
measure_usage_from         |
entitlement_type           | static
issue_after_reset          |
is_soft_limit              |
config                     | "eyJ4eHgiOiAxfQ=="
usage_period_interval      |
usage_period_anchor        |
current_usage_period_start |
current_usage_period_end   |
feature_key                | feature1
issue_after_reset_priority |

The config seems to be a base64 encoded version of:

# echo eyJ4eHgiOiAxfQ== | base64 -d
{"xxx": 1}

But the table has the following schema:

                              Table "public.entitlements"
           Column           |           Type           | Collation | Nullable | Default
----------------------------+--------------------------+-----------+----------+---------
 id                         | character(26)            |           | not null |
 namespace                  | character varying        |           | not null |
 metadata                   | jsonb                    |           |          |
 created_at                 | timestamp with time zone |           | not null |
 updated_at                 | timestamp with time zone |           | not null |
 deleted_at                 | timestamp with time zone |           |          |
 feature_id                 | character(26)            |           | not null |
 subject_key                | character varying        |           | not null |
 measure_usage_from         | timestamp with time zone |           |          |
 entitlement_type           | character varying        |           | not null |
 issue_after_reset          | double precision         |           |          |
 is_soft_limit              | boolean                  |           |          |
 config                     | jsonb                    |           |          |
 usage_period_interval      | character varying        |           |          |
 usage_period_anchor        | timestamp with time zone |           |          |
 current_usage_period_start | timestamp with time zone |           |          |
 current_usage_period_end   | timestamp with time zone |           |          |
 feature_key                | character varying        |           | not null |
 issue_after_reset_priority | smallint                 |           |          |

So I would expect the config field to contain a json string, not a base64 encoded json value (I suppose that's the []byte's encoding).

The schema seems up to date:

field.JSON("config", []byte{}).SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}).Optional(),

		field.JSON("config", []byte{}).SchemaType(map[string]string{
			dialect.Postgres: "jsonb",
		}).Optional(),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions