Repository: readthedocs/readthedocs.org

Issue:
Environmental Variable character limit is 256
Hello all,

I use a private PyPi hosting service (Azure Artifacts) which generates very long URLs to connect with.

Right now when I go to set an environmental variable through the readthedocs.com UI, I cannot enter the number of characters I need.

The limit appears to be 256. My URL is almost 1000 characters.

This is currently blocking my company's ability to generate documentation, as we need this link available to pip in order to install all of our library's dependencies.


Discussion:
Now that's a URL!

We're not familiar with Azure Artifacts, and so don't directly support it yet. I don't think there is any strong reason to keep our env vars limited to 256 characters however. Is it possible to provide a (scrubbed!) URL for an example? I guess I'm mostly curious if these URLs are always going to be <1000 chars, or if there is a better value we can use here. Scanning docs very quickly, I'm not seeing a good example.
Hi!

Here's a dummy example URL:


> https://feed_name:tP_ApznIPANuTyDxgc8RfcDy9-7rjmCc6FacRtBMCe-jJuQjidVqIyUZ4W67H1zjXBASBzUE2OaGFbK90qTuybPw3myp5aZDOC0s7-OqxqWC84Mbq6VVgdAkoo_v7b5TIB7buCUdgE9f5p4tATmoZbWJ2fRUsAnSxIn3QaF3Yy9irMTmyYWCXihsqMmICQzcu_AO40TExbnAKPgxo5t-e6QbBALB2Ui3Q6aZ2_v4wkplNqKk6_YZFzbeS7umOqXColpRm28JB8N75KvkGuQsSnAUei8EYL39-0yJWZjorrYsJODiPjwKiYFGcODcyM1f-FSvF3JFcH_uve1XcMAIk5VEazcI5lrpYT8pL-3t1GEIJO2Y9bZ8ZnCJ4X8IYiY381n_sIy93bArsg4UdpvIUmw6EHXhkDs83AOsn_tFf5I2a8OKOqkxJRUC0_nLnQZtaJtcG0i5Tf18xQKt6Xf9uVjCAFB3U3eL3dmlmCius_79Xy_UXicOgclSjcpv9dd6LDGyZHRS3HjG_glWmKPfyMh8Zi7vTCjBmnHLI7bEarQ1O4IYkTjKLM2O4-4qqxyZwPlOXwHlEbtKDSTsisczzTLR3YeEe1PZo4A8kdDDfg9qM6ehhkxqPDkExGi6LR9CewksBCU9Jvdr0tNkMn7RSO3bD649vySdmFsRF-SqNGS8yS-1PTo8vKuWaQnY0me5VxWr3v_bQNIAy09VM24E84LaOAHAkHSCyaF38reIwSnTTxjS4cTDpG7cQtIOTzpH633mgK98gsifVe4HK9x8BzIUv6wykYX6KvzTRlyi9DSPIxzq4CjRE3ECOQzNZFpaM8v5Vh2ppZ13A1sI7IwgjmaHAI5bLmyz5ptmcq@pkgs.dev.azure.com/org/_packaging/feed_name/pypi/simple/

There's no special handling needed to use Azure Artifacts on your end, since PIP can interact with it natively, I just need to be able to set an environmental variable `PIP_INDEX_URL` to a url like the one above, then `PIP_EXTRA_INDEX_URL` to:

>https://pypi.python.org/simple/

And I'll be off to the races, with PIP able to pull from my private packages during a RTD build.

Thanks for looking into this!
Hey! Just checking back to see what the timetable for something like this usually is.

Not trying to add pressure, just want to be able to plan ahead. Thanks so much for looking into it!
@agjohnson which would be the max length here?
can I work on This?
What Should be the max_length for this Field?
https://github.com/rtfd/readthedocs.org/blob/cca41b7b023f44267f7d5214eafcda33bf3ef7e4/readthedocs/projects/models.py#L1381-L1384


@stsewd Can we convert it to TextField?
I have no opinion on field length. Feel free to refer to other examples of CI services, or Heroku, and support for URLs from Azure Artifacts.
@agjohnson 
**Heroku:** `Config var data (the combination of all keys and values) cannot exceed 32kb for each app.` 
**ref:** https://devcenter.heroku.com/articles/config-vars#config-var-policies

**Azure:** Request URL size: `The maximum size for a request URL is 2,048 chars.`
**ref:** https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#application-gateway-limits
Hello -- just wanted to check back since I am still unable to build our docks. Thanks again to you all for looking into this.

My own two cents: for my particular use case 2048 is more than long enough since I am concerned with Azure Artifact URL's
I'd say it depends on what kind of data users want to put as an env variable, it could be a path file, a URL, private keys, etc. For the first two cases we are safe with 2048.
@stsewd should I open a PR for this with 2048 max_length?
Just checking back in. This is still blocking using RTD for our documentation.

Would it be possible to update to 2048, then leave this ticket open for any further discussion the devs would like to have long-term?
2048 seems fine

Resolving patch:
diff --git a/readthedocs/projects/migrations/0042_increase_env_variable_value_max_length.py b/readthedocs/projects/migrations/0042_increase_env_variable_value_max_length.py
new file mode 100644
--- /dev/null
+++ b/readthedocs/projects/migrations/0042_increase_env_variable_value_max_length.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-04-16 18:43
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('projects', '0041_index-repo-field'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='environmentvariable',
+            name='value',
+            field=models.CharField(help_text='Value of the environment variable', max_length=2048),
+        ),
+    ]
diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -1429,7 +1429,7 @@ class EnvironmentVariable(TimeStampedModel, models.Model):
         help_text=_('Name of the environment variable'),
     )
     value = models.CharField(
-        max_length=256,
+        max_length=2048,
         help_text=_('Value of the environment variable'),
     )
     project = models.ForeignKey(


Test patch: