| Message ID | 20260115182719.2066962-1-daiane.angolini@foundries.io |
|---|---|
| State | New |
| Headers | show |
| Series | [bitbake-devel,v2] bitbake-setup: fail if the url is not a json | expand |
Thanks, I think this is fine. Alex On Thu, 15 Jan 2026 at 19:27, Daiane Angolini via lists.openembedded.org <daiane.angolini=foundries.io@lists.openembedded.org> wrote: > > In those cases when the user enters a URL that points to the html > representation of a json file, and not the actual json file, we can > at least let them know that the URL point to a file which is not a json. > > It will help when a user copy and paste a URL from a browser and the > tool cannot parse it as json. > > Signed-off-by: Daiane Angolini <daiane.angolini@foundries.io> > --- > bin/bitbake-setup | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/bin/bitbake-setup b/bin/bitbake-setup > index abe7614c8..f9880feb1 100755 > --- a/bin/bitbake-setup > +++ b/bin/bitbake-setup > @@ -527,8 +527,12 @@ def obtain_config(top_dir, settings, args, source_overrides, d): > elif config_id.startswith("http://") or config_id.startswith("https://"): > logger.info("Reading configuration from network URI\n {}".format(config_id)) > import urllib.request > - with urllib.request.urlopen(config_id) as f: > - upstream_config = {'type':'network','uri':config_id,'name':get_config_name(config_id),'data':json.load(f)} > + try: > + with urllib.request.urlopen(config_id) as f: > + json_data = json.load(f) > + upstream_config = {'type':'network','uri':config_id,'name':get_config_name(config_id),'data':json_data} > + except json.JSONDecodeError as e: > + raise Exception ("Invalid JSON from {}. Are you pointing to an HTML page? {}".format(config_id, e)) > else: > logger.info("Looking up config {} in configuration registry".format(config_id)) > registry_path = update_registry(settings["default"]["registry"], cache_dir(top_dir), d) > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#18789): https://lists.openembedded.org/g/bitbake-devel/message/18789 > Mute This Topic: https://lists.openembedded.org/mt/117284394/1686489 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index abe7614c8..f9880feb1 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -527,8 +527,12 @@ def obtain_config(top_dir, settings, args, source_overrides, d): elif config_id.startswith("http://") or config_id.startswith("https://"): logger.info("Reading configuration from network URI\n {}".format(config_id)) import urllib.request - with urllib.request.urlopen(config_id) as f: - upstream_config = {'type':'network','uri':config_id,'name':get_config_name(config_id),'data':json.load(f)} + try: + with urllib.request.urlopen(config_id) as f: + json_data = json.load(f) + upstream_config = {'type':'network','uri':config_id,'name':get_config_name(config_id),'data':json_data} + except json.JSONDecodeError as e: + raise Exception ("Invalid JSON from {}. Are you pointing to an HTML page? {}".format(config_id, e)) else: logger.info("Looking up config {} in configuration registry".format(config_id)) registry_path = update_registry(settings["default"]["registry"], cache_dir(top_dir), d)
In those cases when the user enters a URL that points to the html representation of a json file, and not the actual json file, we can at least let them know that the URL point to a file which is not a json. It will help when a user copy and paste a URL from a browser and the tool cannot parse it as json. Signed-off-by: Daiane Angolini <daiane.angolini@foundries.io> --- bin/bitbake-setup | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)