<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15113</bug_id>
          
          <creation_ts>2023-05-04 12:35:51 +0000</creation_ts>
          <short_desc>Using floating tag in SRCREV results in Fetcher Error</short_desc>
          <delta_ts>2023-06-28 22:32:45 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>4.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sergiu Tainescu">sergiu.tainescu</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>95494</commentid>
    <comment_count>0</comment_count>
    <who name="Sergiu Tainescu">sergiu.tainescu</who>
    <bug_when>2023-05-04 12:35:51 +0000</bug_when>
    <thetext>Using a floating tag in any recipe&apos;s SRCREV, either by specifying the value directly or by setting it to PV, results in the following error (used vim as quick example):

ERROR: vim-9.0.1429-r0 do_fetch: Bitbake Fetcher Error: FetchError(&quot;Recipe uses a floating tag/branch &apos;v9.0.1429&apos; for repo &apos;github.com/vim/vim.git&apos; without a fixed SRCREV yet doesn&apos;t call bb.fetch2.get_srcrev() (use SRCPV in PV for OE).&quot;, None)

The patch responsible for adding the new error is: https://lists.openembedded.org/g/bitbake-devel/topic/89051455#13338

It is unclear if this behavior is expected or not, on the one hand the discussion from the link above and the patch&apos;s description suggest that setting SRCREV to a tag instead of a full version identifier can introduce issues.

On the other hand, the error message suggests that it is possible and also says &quot;use SRCPV in PV for OE&quot;. Doing this also doesn&apos;t work and triggers a circular reference error. 

It seems that SRCPV which is set to bb.fetch2.get_srcrev(d) does not get expanded before fetching which triggers the fetcher error error added in _latest_revisions()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95774</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-06-21 12:47:51 +0000</bug_when>
    <thetext>I don&apos;t really understand the issue here. If I apply a patch like this:

diff --git a/meta/recipes-support/vim/vim.inc b/meta/recipes-support/vim/vim.inc
index 33ae0d80797..3b1c83a6b97 100644
--- a/meta/recipes-support/vim/vim.inc
+++ b/meta/recipes-support/vim/vim.inc
@@ -12,15 +12,14 @@ RSUGGESTS:${PN} = &quot;diffutils&quot;
 LICENSE = &quot;Vim&quot;
 LIC_FILES_CHKSUM = &quot;file://LICENSE;md5=6b30ea4fa660c483b619924bc709ef99&quot;
 
-SRC_URI = &quot;git://github.com/vim/vim.git;branch=master;protocol=https \
+SRC_URI = &quot;git://github.com/vim/vim.git;branch=master;protocol=https;tag=v9.0.1592 \
            file://disable_acl_header_check.patch \
            file://vim-add-knob-whether-elf.h-are-checked.patch \
            file://0001-src-Makefile-improve-reproducibility.patch \
            file://no-path-adjust.patch \
            &quot;
 
-PV .= &quot;.1592&quot;
-SRCREV = &quot;29b4c513b11deb37f0e0538df53d195f602fa42c&quot;
+PV = &quot;9.0.1592+git${SRCPV}&quot;
 
 # Remove when 8.3 is out
 UPSTREAM_VERSION_UNKNOWN = &quot;1&quot;

it works fine?

Yes, you need to put SRCPV in PV if you use a floating tag but the message is telling you to do that...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95780</commentid>
    <comment_count>2</comment_count>
    <who name="Sergiu Tainescu">sergiu.tainescu</who>
    <bug_when>2023-06-22 06:44:32 +0000</bug_when>
    <thetext>Yes, that works if setting the tag in SRC_URI but before the changes from https://lists.openembedded.org/g/bitbake-devel/topic/89051455#13338, I could set SRCREV = $PV, where PV would default to the version from the recipe&apos;s name, this worked without setting the tag in SRC_URI.

Now, if I try to set SRCREV = &quot;$PV+git${SRCPV}&quot; as the error message would indicate and also set tag=$PV in SRC_URI, I get:

bb.data_smart.ExpansionError: Failure expanding variable SRCPV, expression was ${@bb.fetch2.get_srcrev(d)} which triggered exception FetchError: Fetcher failure: There are recursive references in fetcher variables, likely through SRC_URI
The variable dependency chain for the failure is: SRCPV -&gt; SRCREV -&gt; SRCPV -&gt; SRCREV

Is the fact that the tag needs to be set explicitly and not parsed from the recipe name intentional? Was the previous usage not intended to work?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95781</commentid>
    <comment_count>3</comment_count>
      <attachid>4957</attachid>
    <who name="Sergiu Tainescu">sergiu.tainescu</who>
    <bug_when>2023-06-22 06:45:19 +0000</bug_when>
    <thetext>Created attachment 4957
log of ExpansionError when setting SRCREV = &quot;$PV+git${SRCPV}&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95811</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-06-22 15:57:45 +0000</bug_when>
    <thetext>(In reply to Sergiu Tainescu from comment #2)
&gt; Yes, that works if setting the tag in SRC_URI but before the changes from
&gt; https://lists.openembedded.org/g/bitbake-devel/topic/89051455#13338, I could
&gt; set SRCREV = $PV, where PV would default to the version from the recipe&apos;s
&gt; name, this worked without setting the tag in SRC_URI.

One way or another you need to trigger the function call mentioned in the error message. If that function call is not triggered, subtle bugs occur. Those bugs were why the error message was added.

The usual way of doing this is to reference SRCPV as it is set with:

SRCPV = &quot;${@bb.fetch2.get_srcrev(d)}&quot;
 
&gt; Now, if I try to set SRCREV = &quot;$PV+git${SRCPV}&quot; as the error message would
&gt; indicate and also set tag=$PV in SRC_URI, I get:
&gt; 
&gt; bb.data_smart.ExpansionError: Failure expanding variable SRCPV, expression
&gt; was ${@bb.fetch2.get_srcrev(d)} which triggered exception FetchError:
&gt; Fetcher failure: There are recursive references in fetcher variables, likely
&gt; through SRC_URI
&gt; The variable dependency chain for the failure is: SRCPV -&gt; SRCREV -&gt; SRCPV
&gt; -&gt; SRCREV

That isn&apos;t surprising as you&apos;ve created a circular reference where it can&apos;t expand one variable as it refers to the other.

&gt; Is the fact that the tag needs to be set explicitly and not parsed from the
&gt; recipe name intentional? Was the previous usage not intended to work?

It isn&apos;t that it wasn&apos;t intended to work, the previous usage had subtle bugs where things could fail pretty badly due to the fetcher not being in a correct state (such as a build revision changing half way through a build). We added errors to make it clear when there were problems.

To get the tag from a filename, I&apos;d suggest something like:

TAGFROMFILENAME = &quot;${@bb.parse.vars_from_file(d.getVar(&apos;FILE&apos;, False),d)[1] or &apos;1.0&apos;}&quot;

and then reference TAGFROMFILENAME in the SRC_URI.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95815</commentid>
    <comment_count>5</comment_count>
    <who name="Sergiu Tainescu">sergiu.tainescu</who>
    <bug_when>2023-06-23 09:31:39 +0000</bug_when>
    <thetext>Everything is clear now, thank you for your time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95833</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2023-06-28 22:32:45 +0000</bug_when>
    <thetext>Issue resolved as above.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4957</attachid>
            <date>2023-06-22 06:45:19 +0000</date>
            <delta_ts>2023-06-22 06:45:19 +0000</delta_ts>
            <desc>log of ExpansionError when setting SRCREV = &quot;$PV+git${SRCPV}&quot;</desc>
            <filename>expansion-error.log</filename>
            <type>text/x-log</type>
            <size>1865</size>
            <attacher name="Sergiu Tainescu">sergiu.tainescu</attacher>
            
              <data encoding="base64">VHJhY2ViYWNrIChtb3N0IHJlY2VudCBjYWxsIGxhc3QpOgogIEZpbGUgIi9ob21lL3N0YWluZXNj
L3dvcmtzcGFjZS95b2N0by9wb2t5L2JpdGJha2UvbGliL2JiL2RhdGFfc21hcnQucHkiLCBsaW5l
IDQ2MCwgaW4gRGF0YVNtYXJ0LmV4cGFuZFdpdGhSZWZzKHM9JyR7QGJiLmZldGNoMi5nZXRfc3Jj
cmV2KGQpfScsIHZhcm5hbWU9J1NSQ1BWJyk6CiAgICAgICAgICAgICAgICAgICAgIHRyeToKICAg
ID4gICAgICAgICAgICAgICAgICAgIHMgPSBfX2V4cGFuZF9weXRob25fcmVnZXhwX18uc3ViKHZh
cnBhcnNlLnB5dGhvbl9zdWIsIHMpCiAgICAgICAgICAgICAgICAgICAgIGV4Y2VwdCBTeW50YXhF
cnJvciBhcyBlOgogIEZpbGUgIi9ob21lL3N0YWluZXNjL3dvcmtzcGFjZS95b2N0by9wb2t5L2Jp
dGJha2UvbGliL2JiL2RhdGFfc21hcnQucHkiLCBsaW5lIDE1MCwgaW4gVmFyaWFibGVQYXJzZS5w
eXRob25fc3ViKG1hdGNoPTxyZS5NYXRjaCBvYmplY3Q7IHNwYW49KDAsIDI3KSwgbWF0Y2g9JyR7
QGJiLmZldGNoMi5nZXRfc3JjcmV2KGQpfSc+KToKICAgICAgICAgICAgICAgICAgICAgICAgIHNl
bGYuY29udGFpbnNba10udXBkYXRlKHBhcnNlci5jb250YWluc1trXSkKICAgID4gICAgICAgICAg
ICB2YWx1ZSA9IHV0aWxzLmJldHRlcl9ldmFsKGNvZGVvYmosIERhdGFDb250ZXh0KHNlbGYuZCks
IHsnZCcgOiBzZWxmLmR9KQog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