<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Houssain El marouni</title>
    <description>The latest articles on DEV Community by Houssain El marouni (@houssain_elmarouni_09942).</description>
    <link>https://dev.to/houssain_elmarouni_09942</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3866584%2F4fda68a9-0eaa-42d6-9174-d1cc4e5b8dfa.jpg</url>
      <title>DEV Community: Houssain El marouni</title>
      <link>https://dev.to/houssain_elmarouni_09942</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/houssain_elmarouni_09942"/>
    <language>en</language>
    <item>
      <title>A silent || 4.0 gave every place on Earth the same sunshine</title>
      <dc:creator>Houssain El marouni</dc:creator>
      <pubDate>Sat, 07 Nov 2026 02:14:08 +0000</pubDate>
      <link>https://dev.to/houssain_elmarouni_09942/a-silent-40-gave-every-place-on-earth-the-same-sunshine-hgo</link>
      <guid>https://dev.to/houssain_elmarouni_09942/a-silent-40-gave-every-place-on-earth-the-same-sunshine-hgo</guid>
      <description>&lt;p&gt;A technical write-up of the NASA bug, ready to paste. DEV requires AI-assisted posts to say so and forbids them from promoting a business, so it ends with a disclosure line and carries no pitch. Your LinkedIn already told this story on 1 Oct, so don't repost it there.&lt;br&gt;
Title: A silent || 4.0 gave every place on Earth the same sunshine&lt;br&gt;
Tags: typescript, javascript, testing, debugging&lt;br&gt;
My solar calculator once told Fuengirola in Spain and Tétouan in Morocco that they would save exactly the same energy: 4,203 kWh a year, €1,050.70. The response said the irradiance came from NASA. It didn't.&lt;br&gt;
The bug&lt;br&gt;
NASA POWER returns monthly values keyed YYYYMM: 202201, 202202, and so on. My code built its keys from a list of month names, so it asked for 2022JAN. All twelve lookups missed.&lt;br&gt;
The read had defaults: || 4.0 for irradiance and || 15.0 for temperature. Each miss quietly became 4.0, so every location on Earth got the same twelve numbers, and the response still reported live NASA data.&lt;br&gt;
Nothing crashed and nothing logged. The numbers looked plausible, and that is the problem: once a plausible default is in the output, nobody can tell it from data.&lt;br&gt;
The fix, and what it found&lt;br&gt;
With the key format fixed, Fuengirola came out at 3,702 kWh and Tétouan at 3,786 kWh for 2022. The old figure was 13.5% too high for Fuengirola.&lt;br&gt;
The same response held two more traps:&lt;br&gt;
• NASA POWER marks a month with no data as -999. That value is finite, so Number.isFinite, the only guard the code had, accepted it as an irradiance reading. The code now compares against the documented fill value exactly.&lt;br&gt;
• NASA appends a thirteenth key, YYYY13, holding the annual mean. Reading the months off Object.keys() would give thirteen entries and a wrong annual figure. The month list is now explicit.&lt;br&gt;
The rule it left&lt;br&gt;
A missing input is reported as missing, never replaced by a plausible number. In practice:&lt;br&gt;
• When NASA POWER can't be used, the calculator answers with a typed 503, nasa_unavailable, and no figure, instead of estimating from latitude.&lt;br&gt;
• When a country has no official tariff, the money line shows "pending".&lt;br&gt;
• The tests that pin this run against responses captured from live NASA POWER and Nominatim, so they still mean something without a network.&lt;br&gt;
What to check in your own code&lt;br&gt;
Search for ||  and ??  on anything read from an external API. Each one is a place where a failed lookup can turn into a confident answer. Ask whether the caller would rather get the default or an error. In my case the honest answer was always the error.&lt;br&gt;
The fix and its tests are public: &lt;a href="https://github.com/elmaroun07-hub/voltura" rel="noopener noreferrer"&gt;https://github.com/elmaroun07-hub/voltura&lt;/a&gt; (see artifacts/api-server/src/routes/calculate.test.ts).&lt;br&gt;
Drafted with AI help; every number was checked against the repo.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>debugging</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
