Skip to contentSkip to conversation

Add missing SRCREV check for SCM URIs

PATCH Superseded Sai Sneha 4 participants 12 messages May 27 – Jun 3 1 message not in the archive

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Sai Sneha

author
#0 lore raw

v4 cover Add missing SRCREV check for SCM URIs

This patch series adds a check for git:// (and other SCM) URIs in SRC_URI that are missing a corresponding SRCREV, addressing Bugzilla #16051 [1] and referencing Corentin Guillevic's RFC series [2].

== Changes since v3 ==

- Factored common SRCREV checking logic into shared helper oe.qa.check_uri_srcrev() in oe/qa.py (new Patch 1)
- Eliminates code duplication across base.bbclass, insane.bbclass and yocto-check-layer.bbclass
- Used for-else pattern, f-strings, simplified name lookup per review
- Renamed raw to rev for clarity
- Added docstrings explaining return values
- Added changelogs to each patch
- Corrected characterization of Corentin patches 3 and 4

== Note on CHECKLAYER_REQUIRED_TESTS ==

Paul suggested using CHECKLAYER_REQUIRED_TESTS instead of Patch 4. We tested this but found it promotes missing-srcrev to ERROR_QA for ALL layers globally during normal builds, because CHECKLAYER_REQUIRED_TESTS feeds directly into ERROR_QA. This contradicts Bug 16051 Comment 3 which requests keeping it as a warning for external layers by default. The direct implementation in yocto-check-layer.bbclass enforces it strictly only during checklayer validation without affecting normal builds.

== Note on candidates list order ==

Martin suggested reversing the candidates list so plain SRCREV is tested first. We kept most-specific-first order because it mirrors BitBake internal srcrev_internal_helper() resolution order exactly, as confirmed by BitBake own error messages:
SRCREV_default:pn-X, SRCREV_default, SRCREV:pn-X, SRCREV

== Problem ==

A recipe with a git:// URI and no SRCREV causes two problems:

1. Under BB_NO_NETWORK=1, parsing fails with a FetchError that halts parsing of ALL recipes. This breaks CI pipelines that use bitbake --parse-only as a sanity check.

2. Without BB_NO_NETWORK, BitBake silently queries the remote repository on every parse, breaking reproducibility.

== Why the trivial fix does not work ==

The obvious fix of checking SRCREV in insane.bbclass do_recipe_qa was attempted by Corentin Guillevic [2] but fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time BEFORE QA checks run. Corentin patches 1 and 2 add the QA check, while patches 3 and 4 ensure devtool and recipetool only use AUTOREV when appropriate.

== This series approach ==

We intercept at the vardepvalue expansion point in base.bbclass using a shared helper oe.qa.check_uri_srcrev() that uses d.getVar(candidate, False) preventing expansion entirely.

== Design decisions ==

1. Why not use srcrev_internal_helper()

It expands SRCREV internally, triggering get_autorev() and live network fetches. Our fallback chain mirrors BitBake resolution order exactly without expansion.

2. Why duplicate warnings at parse time AND QA time

Parse-time catches CI parse-only pipelines. QA-time gives proper layer control. This pattern is established - src-uri-bad does same.

3. Why hardcode git/gitsm/hg/svn schemes

Known limitation, noted as follow-on improvement.

== Enforcement levels ==

  Normal builds, all layers  ->  WARN_QA
  oe-core layer              ->  ERROR_QA
  yocto-check-layer runs     ->  ERROR

== Testing ==

- Recipe with missing SRCREV -> WARNING/ERROR at parse time
- Recipe with SRCREV = AUTOREV -> silent passthrough
- Recipe with rev= in URI -> no false positive
- Recipe with multiple SCM URIs -> all missing SRCREVs reported
- oe-core recipe -> ERROR instead of WARNING
- yocto-check-layer on layer with missing SRCREV -> FAIL
- 952 other recipes parse cleanly -> 0 errors

[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=16051
[2] https://lore.kernel.org/openembedded-core/[email protected]/
[3] https://lists.openembedded.org/g/openembedded-devel/topic/115911777

Sai Sneha (4):
oe/qa.py: add check_uri_srcrev() helper for SCM URI SRCREV validation base.bbclass: warn when SRCREV is missing for SCM URIs at parse time insane.bbclass: add missing-srcrev QA check for SCM URIs yocto-check-layer.bbclass: enforce missing SRCREV check during layer validation

 meta/classes-global/base.bbclass              | 28 ++++++++++
 meta/classes-global/insane.bbclass            | 13 +++++
 meta/classes-global/yocto-check-layer.bbclass | 15 ++++++
 meta/lib/oe/qa.py                             | 30 +++++++++++
 4 files changed, 86 insertions(+), 2 deletions(-)

--
Note: This patch series was developed with assistance from Anthropic Claude (AI). All code has been reviewed, tested, and verified by the contributor. The Signed-off-by line represents the contributor own certification per the Developer Certificate of Origin.

author
#1 lore raw

PATCH v4 1/4 oe/qa.py: add check_uri_srcrev() helper for SCM URI SRCREV validation

Add a shared helper function check_uri_srcrev() that checks whether a single SCM URI has a valid SRCREV set in the datastore.

The function uses unexpanded getVar() calls (False flag) to safely inspect SRCREV without triggering AUTOREV expansion or live network fetches. It mirrors BitBake's internal SRCREV resolution fallback chain exactly:
SRCREV_<name>:pn-<recipe>, SRCREV_<name>, SRCREV:pn-<recipe>, SRCREV

Returns:
- The revision string if a valid SRCREV is found
- '' for non-SCM URIs or URIs with inline rev= parameter (skip)
- None if SRCREV is missing or INVALID

This shared helper is used by base.bbclass, insane.bbclass and yocto-check-layer.bbclass to avoid duplicating the same logic.

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- New patch: factored common SRCREV checking logic into shared helper
- Eliminates code duplication across base.bbclass, insane.bbclass and yocto-check-layer.bbclass
- Uses for-else pattern, f-strings, simplified name lookup
- Adds docstring explaining return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag

Changes in v2:
- Initial public submission

 meta/lib/oe/qa.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
meta/lib/oe/qa.py +30 -0
index cd36cb5070..3505e2492c 100644
@@ -240,6 +240,36 @@ def check_upstream_status(fullpath):
             else:
                 return "Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines)
 
+def check_uri_srcrev(pn, uri, d):
+    """
+    Check that a single SCM URI has a valid SRCREV set.
+
+    Returns the resolved revision string if valid (including '${AUTOREV}').
+    Returns '' for non-SCM URIs or URIs with inline rev= parameter (skip).
+    Returns None if SRCREV is missing or INVALID.
+    """
+    import bb.fetch2
+    try:
+        (scheme, _, _, _, _, params) = bb.fetch2.decodeurl(uri)
+    except Exception:
+        return ''
+    if scheme not in ('git', 'gitsm', 'hg', 'svn'):
+        return ''
+    if params.get('rev', ''):
+        return ''
+    name = params.get('name', 'default')
+    candidates = [
+        f'SRCREV_{name}:pn-{pn}',
+        f'SRCREV_{name}',
+        f'SRCREV:pn-{pn}',
+        'SRCREV',
+    ]
+    for candidate in candidates:
+        rev = d.getVar(candidate, False)
+        if rev and rev != 'INVALID':
+            return rev
+    return None
+
 if __name__ == "__main__":
     import sys
 
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v4 2/4 base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

In reply to Sai Sneha

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
meta/classes-global/base.bbclass +28 -2
index 62f2814bb7..7de896ca7d 100644
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True):
 
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n  %s" % " ".join(notfound))
+    
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True, False, d):
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True, False, d):
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True
+ 
 
 # We can't use vardepvalue against do_fetch directly since that would overwrite
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"
 addtask fetch
 do_fetch[dirs] = "${DL_DIR}"
 do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
Signature · 1 line
2.34.1
#3 lore raw

Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Quoted 84 lines · Sai Sneha via lists.openembedded.org

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
meta/classes-global/base.bbclass +26 -0
index 62f2814bb7..7de896ca7d 100644
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True):
 
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n  %s" % " ".join(notfound))
+    
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True, False, d):
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True, False, d):
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True): · line 200

Quoted 10 lines
meta/classes-global/base.bbclass +2 -2
+ 
 
 # We can't use vardepvalue against do_fetch directly since that would overwrite
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

How confident are you that this is a safe change to make?

This is an area where I would not make AI-driven changes myself, as a change here could cause quite subtle issues. We may not have sufficient test coverage to catch such issues.

Specifically, what happens if a SRC_URI has a 'tag=...' property, SRCREV is not set, and the tag is changed upstream?

Best regards,

Signature · 1 line
Paul Barker
author
#4 lore raw

Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Hi Paul,

You were right to raise the tag= concern — it turned out to be exactly the cause of the selftest failure reported by Mathieu. Recipes using tag= in SRC_URI intentionally leave SRCREV empty, and my check was incorrectly treating this as missing.

The fix adds tag= to the list of URI parameters that bypass the SRCREV check, alongside the existing rev= handling:

if params.get('rev', '') or params.get('tag', ''):
return ''

I have verified the fix by running the full bbtests.BitbakeTests selftest suite — 32/33 passed. The one failure (test_image_manifest) requires building a full image and fails due to network constraints in my environment, unrelated to this patch.

I have sent v5 with this fix.

Best regards,
Sai Sneha

Quoted 120 lines · Paul Barker
Quoted 45 lines · Sai Sneha via lists.openembedded.org

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Review

Quoted 6 lines

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/meta/classes-global/base.bbclass

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d,

Quoted 4 lines

index 62f2814bb7..7de896ca7d 100644

meta/classes-global/base.bbclass +0 -0
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d,

fatal=True):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 165

Quoted 3 lines
meta/classes-global/base.bbclass +0 -0
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by

HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound))

Quoted 9 lines
meta/classes-global/base.bbclass +9 -0
+
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 10 lines
meta/classes-global/base.bbclass +10 -0
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 186

Quoted 2 lines
meta/classes-global/base.bbclass +2 -0
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 8 lines
meta/classes-global/base.bbclass +6 -0
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True
+
 
 # We can't use vardepvalue against do_fetch directly since that would

overwrite

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 7 lines
meta/classes-global/base.bbclass +1 -2
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)

if check_srcrev_set(d) else ''}"

How confident are you that this is a safe change to make?

This is an area where I would not make AI-driven changes myself, as a change here could cause quite subtle issues. We may not have sufficient test coverage to catch such issues.

Specifically, what happens if a SRC_URI has a 'tag=...' property, SRCREV is not set, and the tag is changed upstream?

Best regards,

--
Paul Barker

#5 lore raw

RE: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

I was under the impression that a tag= in the SRC_URI is there to complement the SRCREV, not replace it. I.e., SRCREV should always exist, and if a tag= also exists then it is verified that it matches the SRCREV.

//Peter

From: [email protected] <[email protected]> On Behalf Of Sai Sneha via lists.openembedded.org
Sent: den 2 juni 2026 08:39
To: Paul Barker <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Hi Paul,

You were right to raise the tag= concern — it turned out to be exactly the cause of the selftest failure reported by Mathieu. Recipes using tag= in SRC_URI intentionally leave SRCREV empty, and my check was incorrectly treating this as missing.

The fix adds tag= to the list of URI parameters that bypass the SRCREV check, alongside the existing rev= handling:

if params.get('rev', '') or params.get('tag', ''):
return ''

I have verified the fix by running the full bbtests.BitbakeTests selftest suite — 32/33 passed. The one failure (test_image_manifest) requires building a full image and fails due to network constraints in my environment, unrelated to this patch.

I have sent v5 with this fix.

Best regards,
Sai Sneha
On Thu, 28 May 2026 at 8:39 PM, Paul Barker <[email protected]<mailto:[email protected]>> wrote:

Quoted 84 lines · Sai Sneha via lists.openembedded.org

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}<mailto:$%[email protected]_hashvalue(d)%20if%20check_srcrev_set(d)%20else%20''%7d>"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
meta/classes-global/base.bbclass +26 -0
index 62f2814bb7..7de896ca7d 100644
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True):
 
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n  %s" % " ".join(notfound))
+
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa<http://oe.qa>
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True, False, d):
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True, False, d):
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True): · line 200

Quoted 10 lines
meta/classes-global/base.bbclass +2 -2
+
 
 # We can't use vardepvalue against do_fetch directly since that would overwrite
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}<mailto:$%[email protected]_hashvalue(d)%7d>"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}<mailto:$%[email protected]_hashvalue(d)%20if%20check_srcrev_set(d)%20else%20''%7d>"

How confident are you that this is a safe change to make?

This is an area where I would not make AI-driven changes myself, as a change here could cause quite subtle issues. We may not have sufficient test coverage to catch such issues.

Specifically, what happens if a SRC_URI has a 'tag=...' property, SRCREV is not set, and the tag is changed upstream?

Best regards,

--
Paul Barker

author
#6 lore raw

Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Hi all,

Thank you for the thorough review. I clearly need to step back and rethink the approach before sending more patches. I will continue the discussion on the bug tracker.

Best regards,
Sai Sneha

Quoted 167 lines · Peter Kjellerstedt

I was under the impression that a tag= in the SRC_URI is there to complement the SRCREV, not replace it. I.e., SRCREV should always exist, and if a tag= also exists then it is verified that it matches the SRCREV.

//Peter

*From:* [email protected] < [email protected]> *On Behalf Of *Sai Sneha via lists.openembedded.org
*Sent:* den 2 juni 2026 08:39
*To:* Paul Barker <[email protected]>
*Cc:* [email protected]; [email protected]; [email protected]; [email protected]
*Subject:* Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Hi Paul,

You were right to raise the tag= concern — it turned out to be exactly the cause of the selftest failure reported by Mathieu. Recipes using tag= in SRC_URI intentionally leave SRCREV empty, and my check was incorrectly treating this as missing.

The fix adds tag= to the list of URI parameters that bypass the SRCREV check, alongside the existing rev= handling:

if params.get('rev', '') or params.get('tag', ''):
return ''

I have verified the fix by running the full bbtests.BitbakeTests selftest suite — 32/33 passed. The one failure (test_image_manifest) requires building a full image and fails due to network constraints in my environment, unrelated to this patch.

I have sent v5 with this fix.

Best regards,
Sai Sneha

On Thu, 28 May 2026 at 8:39 PM, Paul Barker <[email protected]> wrote:

Quoted 45 lines · Sai Sneha via lists.openembedded.org

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Review

Quoted 6 lines

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/meta/classes-global/base.bbclass

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d,

Quoted 4 lines

index 62f2814bb7..7de896ca7d 100644

meta/classes-global/base.bbclass +0 -0
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d,

fatal=True):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 165

Quoted 3 lines
meta/classes-global/base.bbclass +0 -0
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by

HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound))

Quoted 9 lines
meta/classes-global/base.bbclass +9 -0
+
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 10 lines
meta/classes-global/base.bbclass +10 -0
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 186

Quoted 2 lines
meta/classes-global/base.bbclass +2 -0
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 8 lines
meta/classes-global/base.bbclass +6 -0
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True
+
 
 # We can't use vardepvalue against do_fetch directly since that would

overwrite

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 7 lines
meta/classes-global/base.bbclass +1 -2
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)

if check_srcrev_set(d) else ''}"

How confident are you that this is a safe change to make?

This is an area where I would not make AI-driven changes myself, as a change here could cause quite subtle issues. We may not have sufficient test coverage to catch such issues.

Specifically, what happens if a SRC_URI has a 'tag=...' property, SRCREV is not set, and the tag is changed upstream?

Best regards,

--
Paul Barker

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#8 lore raw

Re: [OE-core] [PATCH v4 2/4] base.bbclass: warn when SRCREV is missing for SCM URIs at parse time

Hi Paul,

One more thing I wanted to address, your concern about AI-driven changes in this sensitive area.

I understand the concern and I think it is valid. The tag= bug that was caught validates your point, AI-assisted code can miss edge cases. That is precisely why I disclosed the AI involvement honestly, and why your review was valuable in catching it.

To be clear about my role: I used Claude as a development aid, not as a replacement for my own judgment. Every design decision, test, and fix was made by me personally. I reproduced the selftest failure locally, identified the root cause, and applied the correct fix.

I have now run the full bbtests.BitbakeTests suite (32/33 passing). If there are specific additional scenarios you would like me to verify, I am happy to do so.

Best regards,
Sai Sneha

Quoted 155 lines · Sai Sneha via lists.openembedded.org

Hi Paul,

You were right to raise the tag= concern — it turned out to be exactly the cause of the selftest failure reported by Mathieu. Recipes using tag= in SRC_URI intentionally leave SRCREV empty, and my check was incorrectly treating this as missing.

The fix adds tag= to the list of URI parameters that bypass the SRCREV check, alongside the existing rev= handling:

if params.get('rev', '') or params.get('tag', ''):
return ''

I have verified the fix by running the full bbtests.BitbakeTests selftest suite — 32/33 passed. The one failure (test_image_manifest) requires building a full image and fails due to network constraints in my environment, unrelated to this patch.

I have sent v5 with this fix.

Best regards,
Sai Sneha

Quoted 111 lines · Paul Barker
Quoted 45 lines · Sai Sneha via lists.openembedded.org

A recipe with a git:// (or other SCM) URI in SRC_URI must have a corresponding SRCREV set. Without it, BitBake performs a live query on the remote repository at every parse, breaking reproducibility and causing parse failures under BB_NO_NETWORK=1.

The trivial fix of checking SRCREV in insane.bbclass do_recipe_qa fails because fetcher_hashes_dummyfunc[vardepvalue] expands SRCREV at parse time before QA checks run, causing a FetchError that halts parsing entirely. This was identified in Corentin Guillevic's RFC series and confirmed by Mathieu Dubois-Briand's autobuilder testing.

The fix intercepts at the vardepvalue expansion point by introducing check_srcrev_set() which uses the shared oe.qa.check_uri_srcrev() helper. The function is called conditionally:

  fetcher_hashes_dummyfunc[vardepvalue] =
    "${@bb.fetch.get_hashvalue(d) if check_srcrev_set(d) else ''}"

Note on design choice: we intentionally use d.getVar(candidate, False) in oe.qa.check_uri_srcrev() rather than srcrev_internal_helper() because the latter expands SRCREV, triggering get_autorev() and live network fetches -- the exact problem this patch fixes.

Note: parse-time warnings intentionally complement the QA-time warnings added in insane.bbclass. This is necessary because CI pipelines running 'bitbake --parse-only' with BB_NO_NETWORK=1 (the original motivation from Ross Burton) would miss the issue entirely if only QA-time warnings existed. This pattern is already established in the codebase (e.g. src-uri-bad fires at both parse and QA time).

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring explaining True/False return values

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag
- Added design decision notes to commit message

Review

Quoted 6 lines

Changes in v2:
- Initial public submission

 meta/classes-global/base.bbclass | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/meta/classes-global/base.bbclass

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d,

Quoted 4 lines

index 62f2814bb7..7de896ca7d 100644

meta/classes-global/base.bbclass +0 -0
@@ -164,14 +164,40 @@ def setup_hosttools_dir(dest, toolsvar, d,

fatal=True):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 165

Quoted 3 lines
meta/classes-global/base.bbclass +0 -0
     if notfound and fatal:
         bb.fatal("The following required tools (as specified by

HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound))

Quoted 9 lines
meta/classes-global/base.bbclass +9 -0
+
+def check_srcrev_set(d):
+    """
+    Inspect SRC_URI for SCM URIs missing a valid SRCREV.
+
+    Returns True if all SCM URIs have a valid SRCREV or AUTOREV set,
+    allowing get_hashvalue(d) to proceed normally.
+
+    Returns False if any SCM URI is missing SRCREV, suppressing

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 10 lines
meta/classes-global/base.bbclass +10 -0
+    get_hashvalue(d) to prevent a FetchError parse crash.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            # SRCREV missing — warn and suppress hash expansion
+            if bb.utils.contains('ERROR_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, · line 186

Quoted 2 lines
meta/classes-global/base.bbclass +2 -0
+                bb.error("%s: SRCREV not set for %s" % (pn, uri))
+            elif bb.utils.contains('WARN_QA', 'missing-srcrev', True,

False, d):

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 8 lines
meta/classes-global/base.bbclass +6 -0
+                bb.warn("%s: SRCREV not set for %s" % (pn, uri))
+            return False
+        if rev and '${AUTOREV}' in rev:
+            return True
+    return True
+
 
 # We can't use vardepvalue against do_fetch directly since that would

overwrite

meta/classes-global/base.bbclass def setup_hosttools_dir(dest, toolsvar, d, fatal=True):

Quoted 7 lines
meta/classes-global/base.bbclass +1 -2
 # the other task dependencies so we use an indirect function.
 python fetcher_hashes_dummyfunc() {
     return
 }
-fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}"
-
+fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)

if check_srcrev_set(d) else ''}"

How confident are you that this is a safe change to make?

This is an area where I would not make AI-driven changes myself, as a change here could cause quite subtle issues. We may not have sufficient test coverage to catch such issues.

Quoted 9 lines

Specifically, what happens if a SRC_URI has a 'tag=...' property, SRCREV is not set, and the tag is changed upstream?

Best regards,

--
Paul Barker

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#238005):
https://lists.openembedded.org/g/openembedded-core/message/238005
Mute This Topic: https://lists.openembedded.org/mt/119510786/10302268
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#9 lore raw

PATCH v4 3/4 insane.bbclass: add missing-srcrev QA check for SCM URIs

In reply to Sai Sneha

Add a proper QA check test_missing_srcrev() in do_recipe_qa that fires at build time via oe.qa.handle_error(), using the shared oe.qa.check_uri_srcrev() helper to avoid code duplication.

Severity is controlled per layer:
- WARN_QA:append = " missing-srcrev" for all layers (warning by default)
- ERROR_QA:append:layer-core = " missing-srcrev" for oe-core (strict)

This follows the same pattern as missing-metadata and missing-maintainer which are warnings globally but errors for oe-core.

Note on CHECKLAYER_REQUIRED_TESTS: missing-srcrev is intentionally not added to CHECKLAYER_REQUIRED_TESTS because that would promote it to ERROR_QA for all layers globally during normal builds, contradicting the layer-specific enforcement requested in Bug 16051 Comment 3. Instead, yocto-check-layer.bbclass enforces it directly during checklayer validation runs.

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added note explaining why CHECKLAYER_REQUIRED_TESTS is not used

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag

Changes in v2:
- Initial public submission

 meta/classes-global/insane.bbclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)
meta/classes-global/insane.bbclass +13 -0
index 04700be71c..1fe426646d 100644
@@ -49,6 +49,9 @@ ERROR_QA ?= "\
 ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"
 WARN_QA:append:layer-core = " missing-metadata missing-maintainer"
 
+WARN_QA:append = " missing-srcrev"
+ERROR_QA:append:layer-core = " missing-srcrev"
+
 FAKEROOT_QA = "host-user-contaminated"
 FAKEROOT_QA[doc] = "QA tests which need to run under fakeroot. If any \
 enabled tests are listed here, the do_package_qa task will run under fakeroot."
@@ -1455,6 +1458,15 @@ python do_qa_unpack() {
 python do_recipe_qa() {
     import re
 
+    def test_missing_srcrev(pn, d):
+        import oe.qa
+        src_uri = (d.getVar('SRC_URI', False) or '').split()
+        for uri in src_uri:
+            rev = oe.qa.check_uri_srcrev(pn, uri, d)
+            if rev is None:
+                oe.qa.handle_error("missing-srcrev",
+                    "%s: SRCREV not set for SCM URI %s" % (pn, uri), d)
+         
     def test_naming(pn, d):
         if pn.endswith("-native") and not bb.data.inherits_class("native", d):
             oe.qa.handle_error("recipe-naming", "Recipe %s appears native but is not, should inherit native" % pn, d)
@@ -1497,6 +1509,7 @@ python do_recipe_qa() {
 
     pn = d.getVar('PN')
     test_naming(pn, d)
+    test_missing_srcrev(pn, d)
     test_missing_metadata(pn, d)
     test_missing_maintainer(pn, d)
     test_srcuri(pn, d)
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH v4 4/4 yocto-check-layer.bbclass: enforce missing SRCREV check during layer validation

In reply to Sai Sneha

Add check_missing_srcrev() to yocto-check-layer.bbclass to enforce the missing-srcrev check as an error during yocto-check-layer runs, using the shared oe.qa.check_uri_srcrev() helper.

This ensures layer maintainers submitting layers to the Yocto ecosystem must fix all missing SRCREVs before their layer passes validation, even if their layer only gets WARN_QA during normal builds.

Note on design: missing-srcrev is not added to CHECKLAYER_REQUIRED_TESTS because that would promote it to ERROR_QA for all layers globally during normal builds, contradicting the layer-specific enforcement requested in Bug 16051 Comment 3. This direct implementation in yocto-check-layer.bbclass enforces it strictly during checklayer validation without affecting normal builds.

This satisfies the requirement from Bug 16051 Comment 2:
'add a QA check outside of checklayer then add it to checklayer'

AI-Generated: Developed with assistance from Anthropic Claude

---

Changes in v4:
- Refactored to use shared oe.qa.check_uri_srcrev() helper
- Eliminates duplicated URI parsing logic
- Added docstring

Changes in v3:
- Added AI-Generated disclosure and Reported-by tag

Changes in v2:
- Initial public submission

 meta/classes-global/yocto-check-layer.bbclass | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
meta/classes-global/yocto-check-layer.bbclass +15 -0
index ba93085325..11b7f5d2ee 100644
@@ -56,7 +56,22 @@ def check_network_flag(d):
         if network and not is_allowed(bpn, task):
             bb.error(f"QA Issue: task {task} has network enabled")
 
+def check_missing_srcrev(d):
+    """
+    Enforce missing-srcrev check as error during yocto-check-layer runs.
+    Uses the shared oe.qa.check_uri_srcrev() helper.
+    """
+    import oe.qa
+    src_uri = (d.getVar('SRC_URI', False) or '').split()
+    pn = d.getVar('PN')
+    for uri in src_uri:
+        rev = oe.qa.check_uri_srcrev(pn, uri, d)
+        if rev is None:
+            bb.error("QA Issue: %s: SRCREV not set for SCM URI %s [missing-srcrev]" % (pn, uri))
+            d.setVar("QA_ERRORS_FOUND", "True")
+
 python () {
     check_insane_skip(d)
     check_network_flag(d)
+    check_missing_srcrev(d)
 }
Signature · 1 line
2.34.1
#11 lore raw
In reply to Sai Sneha
Quoted 4 lines · Sai Sneha via lists.openembedded.org

This patch series adds a check for git:// (and other SCM) URIs in SRC_URI that are missing a corresponding SRCREV, addressing Bugzilla #16051 [1] and referencing Corentin Guillevic's RFC series [2].

Hi,

Thanks for your patch.

It looks like this is breaking the test_git_unpack_nonetwork selftest:

2026-05-28 09:51:08,030 - oe-selftest - INFO - bbtests.BitbakeTests.test_git_unpack_nonetwork (subunit.RemotedTestCase)
2026-05-28 09:51:08,030 - oe-selftest - INFO -  ... FAIL

...
ERROR: gitunpackoffline-0.0+git-r0 do_fetch: Bitbake Fetcher Error: FetchError("Recipe uses a floating tag/branch '2.11' for repo 'git.yoctoproject.org/matchbox-panel-2' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/4009
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3916

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#12 lore raw

Hi Mathieu,

Thank you for running the selftests and catching this.

The root cause was that recipes using tag= in SRC_URI (like the gitunpackoffline selftest recipe) intentionally set SRCREV to empty, but my check incorrectly treated empty SRCREV as missing when tag= was present.

The fix skips the SRCREV check when tag= is present in the URI, similar to the existing rev= handling. I verified locally:

oe-selftest -r bbtests.BitbakeTests.test_git_unpack_nonetwork PASSED

I have sent v5 with this fix.

Best regards,
Sai Sneha

Quoted 36 lines · Mathieu Dubois-Briand
Quoted 4 lines · Sai Sneha via lists.openembedded.org

This patch series adds a check for git:// (and other SCM) URIs in SRC_URI that are missing a corresponding SRCREV, addressing Bugzilla #16051 [1] and referencing Corentin Guillevic's RFC series [2].

Hi,

Thanks for your patch.

It looks like this is breaking the test_git_unpack_nonetwork selftest:

2026-05-28 09:51:08,030 - oe-selftest - INFO -
bbtests.BitbakeTests.test_git_unpack_nonetwork (subunit.RemotedTestCase)
2026-05-28 09:51:08,030 - oe-selftest - INFO -  ... FAIL

...
ERROR: gitunpackoffline-0.0+git-r0 do_fetch: Bitbake Fetcher Error:
FetchError("Recipe uses a floating tag/branch '2.11' for repo ' git.yoctoproject.org/matchbox-panel-2' without a fixed SRCREV yet doesn't call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).", None)

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/4009
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/3916

Can you have a look at the issue?

Thanks,
Mathieu

--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com