[bitbake][wrynose][2.18][PATCH v2 6/8] fetch2: allow empty value for params while formatting URI string.
Yoann Congal <[email protected]> Thu, 11 Jun 2026 15:11:28 +0200
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <52b3bff42f17933595af48654098b172ea10baff.1781183212.git.yoann.congal@smile.fr> |
From: hongxu <[email protected]> While using PREMIRRORS to gets source code, recipe sbom-cve-check-update-nvd-native do fetch failed: $ bitbake sbom-cve-check-update-nvd-native -cfetch -f ... ERROR: sbom-cve-check-update-nvd-native-1.0-r0 do_fetch: Bitbake Fetcher Error: MalformedUrl('git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix') ERROR: Logfile of failure stored in: tmp/work/x86_64-linux/sbom-cve-check-update-nvd-native/1.0/temp/log.do_fetch.4135595 ERROR: Task (oe-core/meta/recipes-devtools/sbom-cve-check/sbom-cve-check-update-nvd-native.bb:do_fetch) failed with exit code '1' ... In oe-core commit [1], destsuffix was configured to empty string through SRC_URI, but in bitbake commit [2], it removed `=' from destsuffix in which value is empty, and trigger MalformedUrl failure, see sbom-cve-check-update-nvd-native do_fetch log: ...log.do_fetch... DEBUG: For url git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix= returning git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix ...log.do_fetch... This commit use function _query_str_join for query as usual (if a value is None then it isn't a key-value pair, but a bare key.), and use function _param_str_join for params to allow value is empty string and still key-value pair, after applying this commit ...log.do_fetch... DEBUG: For url git://github.com/fkie-cad/nvd-json-data-feeds.git;branch=main;protocol=https;destsuffix= returning git:///path-to-premirror/git/github.com.fkie-cad.nvd-json-data-feeds.git;branch=main;protocol=file;destsuffix= ...log.do_fetch... $ bitbake-selftest -v bb.tests.fetch.URITest.test_uri test_uri (bb.tests.fetch.URITest) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.001s OK [1] https://github.com/openembedded/openembedded-core/commit/131e024a6688074347e08879718221fbfb69033f [2] https://github.com/openembedded/bitbake/commit/eac583bd4c46f3bb9661852cb6a1448f16147ff1 Signed-off-by: Hongxu Jia <[email protected]> Signed-off-by: Richard Purdie <[email protected]> (cherry picked from commit b3867e6d35ef57239c7ba961a00fa45577600301) Signed-off-by: Yoann Congal <[email protected]> --- lib/bb/fetch2/__init__.py | 7 +++++-- lib/bb/tests/fetch.py | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index d913d7511..e0494b3cb 100644 --- a/lib/bb/fetch2/__init__.py +++ b/lib/bb/fetch2/__init__.py @@ -304,7 +304,7 @@ class URI(object): def _query_str(self): return ( - ''.join(['?', self._param_str_join(self.query, "&")]) + ''.join(['?', self._query_str_join(self.query, "&")]) if self.query else '') def _param_str_split(self, string, elmdelim, kvdelim="="): @@ -313,9 +313,12 @@ class URI(object): ret[k] = v return ret - def _param_str_join(self, dict_, elmdelim, kvdelim="="): + def _query_str_join(self, dict_, elmdelim, kvdelim="="): return elmdelim.join([kvdelim.join([k, v]) if v else k for k, v in dict_.items()]) + def _param_str_join(self, dict_, elmdelim, kvdelim="="): + return elmdelim.join([kvdelim.join([k, v]) for k, v in dict_.items()]) + @property def hostport(self): if not self.port: diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index cc133c1f5..e661ff0d8 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -292,8 +292,8 @@ class URITest(unittest.TestCase): 'query': {}, 'relative': True }, - "https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip": { - 'uri': 'https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip', + "https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip;someparam=": { + 'uri': 'https://www.innodisk.com/Download_file?9BE0BF6657;downloadfilename=EGPL-T101.zip;someparam=', 'scheme': 'https', 'hostname': 'www.innodisk.com', 'port': None, @@ -303,7 +303,7 @@ class URITest(unittest.TestCase): 'userinfo': '', 'username': '', 'password': '', - 'params': {"downloadfilename" : "EGPL-T101.zip"}, + 'params': {"downloadfilename" : "EGPL-T101.zip", "someparam" : ""}, 'query': {"9BE0BF6657": None}, 'relative': False },