unleash-client-java icon indicating copy to clipboard operation
unleash-client-java copied to clipboard

Sanitize appName for backupFile

Open ajdergute opened this issue 3 years ago • 3 comments

We're evaluating feature flags on GitLab. The first tests are promising. Sadly we ran into issues with backup files on Windows. GitLab enforces to set application name to their "environment". This ist eine for some correlation. See also: https://docs.gitlab.com/ee/operations/feature_flags.html#get-access-credentials

Our environment names are based on branch names. Thus we've environments like follow:

  • feature/foo/bare
  • fix/baz-123456

On Windows this yield into invalid path names. See: https://github.com/Unleash/unleash-client-java/blob/8525a8f56e2198bebcd893e169ae92b556cc8b07/src/main/java/io/getunleash/util/UnleashConfig.java#L605

I recommend to sanitize appName for backup files. What do you think?

ajdergute avatar Oct 14 '22 18:10 ajdergute

Hey @ajdergute, I believe this is actually a bug on the Gitlab side. We by design don't allow slashes in environment names, so you'd need to sanitise those before creating the environments. Would you be able to raise this with the Gitlab team instead?

sighphyre avatar Oct 19 '22 07:10 sighphyre

GitLab by design allows slashes (beside other characters) for it's environment names. Refer to: https://docs.gitlab.com/ee/ci/environments/index.html#create-a-dynamic-environment And: https://docs.gitlab.com/ee/ci/yaml/index.html#environmentname

Please mind, that the "gitlab environment" is mapped to "unleash appName". I'm not aware if this is a good idea.

Anyway, I'm not able to get some restrictions out of unleash documentation. The only information I found is: https://docs.getunleash.io/reference/api/unleash/register-client-application

As per this documentation any string is allowed as appName. If it's on GitLab side it would be very helpful if I could point to some documentation. I'm able to raise this at GitLab, but I'm not convinced that it's really an issue with GitLab.

ajdergute avatar Oct 19 '22 10:10 ajdergute

Ah right, fair enough, I think I've misunderstood your original question, apologies for that! Environment names wouldn't get mapped to app names in Unleash, so it's not practically a problem outside of Gitlab. That aside I can see how it'd be a pain to deal with. The config in this SDK should allow you to set your own backup file path, which is probably what I would suggest. Otherwise, it's open source so if you'd be open to submitting a PR, we'd be open to looking.

sighphyre avatar Oct 20 '22 07:10 sighphyre

Hey, @ajdergute 🙋🏼 We haven't heard from you in a bit now and I see @sighphyre suggested a potential workaround for the backup file path. Did that work out for you? ☺️

As @sighphyre also said, this seems to be an issue with how GitLab uses Unleash and not with this SDK itself, so I'm going to go ahead and close this issue for now. Feel free to re-open it if you think it's warranted, though.

thomasheartman avatar Nov 01 '22 12:11 thomasheartman

Sorry for my late reply. The workaround from @sighphyre doesn't work for me. I created an PR and open for any discussion.

If desired, I'm able to change this PR to make the backupFilePath configurable.

ajdergute avatar Nov 15 '22 19:11 ajdergute