Coder Social home page Coder Social logo

Add json attribute to variants about flipt HOT 7 CLOSED

flipt-io avatar flipt-io commented on May 13, 2024 1
Add json attribute to variants

from flipt.

Comments (7)

markphelps avatar markphelps commented on May 13, 2024 2

Thanks for taking this on and for the PR @amayvs ! I agree I think JSON would be better than storing binary.

Yes for the UI I was thinking we would have a textarea that is optional, and perhaps verify that it is proper JSON before submitting. We'd likely want to do that validation on the server side as well before accepting the JSON and perhaps put a limit to the number of bytes that can be stored?

from flipt.

markphelps avatar markphelps commented on May 13, 2024 1

@kevin-ip honestly I think we can just hardcode the max of the attachment field to be 10kb or something similar. Then if we get a request to make it configurable we could do so later.

10kb of json is quite a lot for a single field I think

I was thinking something like this which I guess does make sense to be in the variant validator

const MAX_VARIANT_ATTACHMENT_SIZE = 10000

bytes, err := json.Marshal(req.Attachment)
if err != nil { ... }

if len(bytes) > MAX_VARIANT_ATTACHMENT_SIZE {
  return errs.InvalidFieldError("attachment", "max json payload size is 10kb")
}

or something similar?

That way we don't have to modify the validator itself to pass in the context or add a new config property

from flipt.

4n70w4 avatar 4n70w4 commented on May 13, 2024

reference: https://checkr.github.io/flagr/#/flagr_use_cases?id=dynamic-configuration

from flipt.

markphelps avatar markphelps commented on May 13, 2024

@4n70w4 thanks for the feature request. I think I can see the value in this, wondering if you think this attachment field should support strictly JSON or any value (like a blob).

Reason being, I don't want to get into validating user input as JSON, but perhaps I dont need to. Whatever the user saves as the value could be returned as an attachment.

What are your thoughts?

from flipt.

4n70w4 avatar 4n70w4 commented on May 13, 2024

@markphelps yes you're right, may be do payload in any format.

from flipt.

amayvs avatar amayvs commented on May 13, 2024

Hi @markphelps, we are currently working on this feature and wanted to get some input about how the field should be represented in the UI.

As per the comments above, we've implemented attachment field as a bytearray, do we expect the UI to have a simple textarea where user can copy/paste data or does it need to do any encoding/decoding?

But we feel that the field would be better served as JSON, and if binary attachment is required, it can be base64 encoded and included to the JSON structure.

Additionally, if you have other general thoughts about this feature then do let us know. Thanks.

Draft PR: #685

from flipt.

kevin-ip avatar kevin-ip commented on May 13, 2024

Hi @markphelps, What would you recommend the default limit to the number of bytes?

I am planning to add a new config, DataConfig (default with 1024 KB), and updating the Validator.Validate() to take a context.Context. The ValidationUnaryInterceptor will set the ctx with dataConfig before invoking Validator.Validate(...). The method will then get the config from the context and compare against the length of the attachment. WDYT?

from flipt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.