You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2026/04/15 21:00:50 UTC

[PR] Fix broken blog Atom feed [airflow-site]

kaxil opened a new pull request, #1500:
URL: https://github.com/apache/airflow-site/pull/1500

   ## Summary
   
   The blog Atom feed at `/blog/index.xml` has been producing invalid XML since it was introduced in #1391, reported in #1490. Three separate issues:
   
   **1. Leading whitespace before XML declaration**
   Hugo strips `{{/* */}}` template comments but preserves surrounding newlines. This produced two blank lines before `<?xml?>`, which the XML spec requires to be at byte 0. Fixed with Hugo's whitespace-trimming markers (`{{- -}}`).
   
   **2. HTML escaping of XML constructs**
   Hugo's `html/template` engine escaped `<?xml` → `&lt;?xml` and `<![CDATA[` → `&lt;![CDATA[`. Most browsers/readers partially recovered from this, but the feed was technically invalid. Fixed by piping through `safeHTML`.
   
   **3. Relative URLs instead of absolute**
   Since `baseURL = "/"`, `.Permalink` produced relative paths like `/blog/common-ai-provider/`. The Atom spec requires absolute URIs in `<link>` and `<id>` elements (this was the original request in #223). Added a `canonicalBaseURL` site param rather than changing the global `baseURL`, which could have unintended side effects across the site.
   
   ## Verification
   
   ```bash
   cd landing-pages/site
   hugo --quiet
   python3 -c "
   import xml.etree.ElementTree as ET
   tree = ET.parse('public/blog/index.xml')
   ns = {'atom': 'http://www.w3.org/2005/Atom'}
   entries = tree.findall('.//atom:entry', ns)
   print(f'Valid XML with {len(entries)} entries')
   link = entries[0].find('atom:link', ns).get('href')
   print(f'Entry link: {link}')
   "
   ```
   
   Output:
   ```
   Valid XML with 37 entries
   Entry link: https://airflow.apache.org/blog/common-ai-provider/
   ```
   
   Closes #1490


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix broken blog Atom feed [airflow-site]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #1500:
URL: https://github.com/apache/airflow-site/pull/1500


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix broken blog Atom feed [airflow-site]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1500:
URL: https://github.com/apache/airflow-site/pull/1500#discussion_r3089364725


##########
landing-pages/site/layouts/blog/list.xml:
##########
@@ -15,29 +15,29 @@
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-*/}}
-
-<?xml version="1.0" encoding="utf-8"?>
+*/ -}}
+{{- $base := .Site.Params.canonicalBaseURL | default "" -}}
+{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
 <feed xmlns="http://www.w3.org/2005/Atom">
   <title>{{ .Site.Title }} Blog</title>
-  <link href="{{ .Permalink }}" rel="alternate"/>
-<link href="{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
-<id>{{ .Permalink }}</id>
+  <link href="{{ $base }}{{ .Permalink }}" rel="alternate"/>
+  <link href="{{ $base }}{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
+  <id>{{ $base }}{{ .Permalink }}</id>
 {{ $pages := sort .Pages "Lastmod" "desc" }}
 {{ with index $pages 0 }}
   <updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z" }}</updated>
 {{ end }}
 {{ range sort .Pages "Lastmod" "desc" }}
   <entry>
     <title>{{ .Title }}</title>
-    <link href="{{ .Permalink }}" rel="alternate"/>
-    <id>{{ .Permalink }}</id>
+    <link href="{{ $base }}{{ .Permalink }}" rel="alternate"/>
+    <id>{{ $base }}{{ .Permalink }}</id>
     <published>{{ .PublishDate.Format "2006-01-02T15:04:05Z" }}</published>
     <updated>{{ .Lastmod.Format "2006-01-02T15:04:05Z" }}</updated>
     <author>
       <name>Apache Airflow</name>
     </author>
-    <content type="html"><![CDATA[{{ .Content }}]]></content>
+    <content type="html">{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}</content>

Review Comment:
   Wrapping `.Content` in a single CDATA section will still generate invalid XML if the rendered HTML ever contains the sequence `]]>` (which terminates CDATA). To keep the feed robust, consider splitting/escaping that sequence before emitting CDATA (or alternatively avoid CDATA and XML-escape the HTML for `type="html"`).
   ```suggestion
       {{- $content := replace .Content "]]>" "]]]]><![CDATA[>" -}}
       <content type="html">{{ printf "<![CDATA[%s]]>" $content | safeHTML }}</content>
   ```



##########
landing-pages/site/layouts/blog/list.xml:
##########
@@ -15,29 +15,29 @@
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-*/}}
-
-<?xml version="1.0" encoding="utf-8"?>
+*/ -}}
+{{- $base := .Site.Params.canonicalBaseURL | default "" -}}
+{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }}
 <feed xmlns="http://www.w3.org/2005/Atom">
   <title>{{ .Site.Title }} Blog</title>
-  <link href="{{ .Permalink }}" rel="alternate"/>
-<link href="{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
-<id>{{ .Permalink }}</id>
+  <link href="{{ $base }}{{ .Permalink }}" rel="alternate"/>
+  <link href="{{ $base }}{{ .Permalink }}index.xml" rel="self" type="application/atom+xml"/>
+  <id>{{ $base }}{{ .Permalink }}</id>

Review Comment:
   Building absolute URLs via `{{ $base }}{{ .Permalink }}` assumes `.Permalink` is a path. If `baseURL` is ever set to an absolute URL (e.g. via CLI/env in other build contexts), `.Permalink` becomes absolute and this concatenation would produce an invalid URL (double scheme/host). Consider using `.RelPermalink` (path-only) and joining with `canonicalBaseURL` (e.g. via `urls.JoinPath` or trimming trailing/leading slashes) for the `<link>`/`<id>` values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org