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

entitlement config db side representation seems off #1187

Open
linear bot opened this issue Jul 11, 2024 · 0 comments
Open

entitlement config db side representation seems off #1187

linear bot opened this issue Jul 11, 2024 · 0 comments

Comments

@linear
Copy link

linear bot commented Jul 11, 2024

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(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants