Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metar response: Invalid field name(s) found: raw_text #79

Closed
wants to merge 1 commit into from

Conversation

rbuj
Copy link
Contributor

@rbuj rbuj commented May 29, 2020

Old URI

https://aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

New URI

https://aviationweather.gov/adds/dataserver1_3/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

Test: Update weather info on mateweather-applet

msg->response_body->data contains raw_text element now

(gdb) set print elements 0
(gdb) print "%s", msg->response_body->data
$3 = 0x16464e0 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<response xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XML-Schema-instance\" version=\"1.2\" xsi:noNamespaceSchemaLocation=\"http://aviationweather.gov/adds/schema/metar1_2.xsd\">\r\n  <request_index>15318</request_index>\r\n  <data_source name=\"metars\" />\r\n  <request type=\"retrieve\" />\r\n  <errors />\r\n  <warnings />\r\n  <time_taken_ms>13</time_taken_ms>\r\n  <data num_results=\"1\">\r\n    <METAR>\r\n      <raw_text>LEDA 291130Z AUTO 18005KT CAVOK 27/12 Q1016</raw_text>\r\n    </METAR>\r\n  </data>\r\n</response>\r\n\r\n"
(gdb) 

metar

Closes #80

Copy link
Member

@vkareh vkareh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick fix!

@muktupavels
Copy link

I would not consider this as fix without having more info... That parameter was used to limit returned data. Now it returns more data, that wont be used...

@vkareh
Copy link
Member

vkareh commented May 29, 2020

@muktupavels has a good point. Regardless of the amount of data, dataserver_current seems like a break in API, whereas dataserver1_3 seems like the actual locked-in version of the API that we've been using up to now (or compatible enough).

I would estimate that dataserver1_3 won't change but dataserver_current can change spec without notice, as it's likely a pointer to whatever new version of their API. Maybe it makes sense to lock in the 1.3 version

@rbuj
Copy link
Contributor Author

rbuj commented May 29, 2020

The current server of AWC is TDS 1.3 (January 2010), which uses metar1_2.xsd. It should be available at the following URLs:

  1. http://aviationweather.gov/dataserver_current/current/
  2. http://aviationweather.gov/adds/dataserver1_3/current/

The 1st server doesn't accept fields=raw_text in Fields constraint, by removing it from the soap request, the response contains the METAR element, what includes raw_text.

	<xsd:element name="METAR">
		<xsd:complexType>
			<xsd:sequence >
				<xsd:element ref="raw_text" minOccurs="0" />
				<xsd:element ref="station_id" minOccurs="0"/>
                                <xsd:element ref="observation_time" minOccurs="0"/>
                                <xsd:element ref="latitude" minOccurs="0"/>
				<xsd:element ref="longitude" minOccurs="0"/>
				<xsd:element ref="temp_c" minOccurs="0"/>
				<xsd:element ref="dewpoint_c" minOccurs="0"/>
				<xsd:element ref="wind_dir_degrees" minOccurs="0"/>
				<xsd:element ref="wind_speed_kt" minOccurs="0"/>
				<xsd:element ref="wind_gust_kt" minOccurs="0"/>
				<xsd:element ref="visibility_statute_mi" minOccurs="0"/>
				<xsd:element ref="altim_in_hg" minOccurs="0"/>
				<xsd:element ref="sea_level_pressure_mb" minOccurs="0"/>
				<xsd:element ref="quality_control_flags" minOccurs="0"/>
				<xsd:element ref="wx_string" minOccurs="0"/>
				<xsd:element ref="sky_condition" minOccurs="0" maxOccurs="4"/>
				<xsd:element ref="flight_category" minOccurs="0"/>
				<xsd:element ref="three_hr_pressure_tendency_mb" minOccurs="0"/>
				<xsd:element ref="maxT_c" minOccurs="0" />
				<xsd:element ref="minT_c" minOccurs="0" />
				<xsd:element ref="maxT24hr_c" minOccurs="0" />
				<xsd:element ref="minT24hr_c" minOccurs="0"/>
				<xsd:element ref="precip_in" minOccurs="0" />
				<xsd:element ref="pcp3hr_in" minOccurs="0"/>
				<xsd:element ref="pcp6hr_in" minOccurs="0"/>
				<xsd:element ref="pcp24hr_in" minOccurs="0"/>
				<xsd:element ref="snow_in" minOccurs="0"/>
				<xsd:element ref="vert_vis_ft" minOccurs="0"/>
				<xsd:element ref="metar_type" minOccurs="0" />
				<xsd:element ref="elevation_m" minOccurs="0" />
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

I have no objection to change the URI base of the request keeping the fields constraint to get only that element:

	<xsd:element name="raw_text" type="xsd:string"/>

@rbuj rbuj force-pushed the weather-metar-soap branch from 6d54cca to 01319a7 Compare May 29, 2020 12:16
@vkareh vkareh self-requested a review May 29, 2020 12:41
Copy link
Member

@vkareh vkareh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this works as well

@raveit65
Copy link
Member

Big thank you for fast reaction to @rbuj
Guys, weather data is back! Do we need the PR?

@rbuj
Copy link
Contributor Author

rbuj commented May 30, 2020

The AWC SOAP WS is back with the same conditions in both URIs, ie no changes need to be made in the request.

@rbuj rbuj closed this May 30, 2020
@rbuj rbuj deleted the weather-metar-soap branch May 30, 2020 12:54
@rbuj rbuj restored the weather-metar-soap branch June 2, 2020 13:08
@rbuj
Copy link
Contributor Author

rbuj commented Jun 2, 2020

Apparently it's still necessary for getting the weather info from METAR database

@rbuj rbuj reopened this Jun 2, 2020
@rbuj rbuj force-pushed the weather-metar-soap branch from 01319a7 to 14270e7 Compare June 2, 2020 14:00
@raveit65
Copy link
Member

raveit65 commented Jun 2, 2020

@rbuj
Do you think that your proposed code change would work with old and new behaviour from AWC ?
Sadly, we don't know if this is a temporary issue by AWC or a change of their API.

@vkareh
Copy link
Member

vkareh commented Jun 2, 2020

I still think that moving to dataserver1_3 might be a good idea. I don't have any inside information, but from poking around at the website I can only assume that dataserver_current is the equivalent to a symlink to the latest version, which used to be 1.3, but now it's not?

If we want to be more paranoid, we can do both and change to dataserver1_3 and drop the fields=raw_text from the request...

@N0rbert
Copy link

N0rbert commented Jun 3, 2020

What is really bad - this fix is needed for all Ubuntu versions.
Did you tried to contact aviationweather.gov admins to ask them changing URL back?
It will be safer to not change the code of libmateweather internals, I think.

What should we do if they change the URL again?
And anyway it would be good to have some configuration place for weather URL (like dconf, gsettings) to change it without recompilation.

@raveit65
Copy link
Member

raveit65 commented Jun 3, 2020

What is really bad - this fix is needed for all Ubuntu versions.

Wrong, it is really bad that all Distros need this!

@N0rbert
Copy link

N0rbert commented Jun 3, 2020

I tried to write an e-mail to NOAA and AviationWeather about reverting their API changes. Will inform you on any reply.
The contact form https://aviationweather.gov/contact does not work, shows error about their proxy server. The API seems to be documented at https://aviationweather.gov/dataserver .

@raveit65
Copy link
Member

raveit65 commented Jun 3, 2020

Thank you.
I am testing this PR since one day now, currently they didn't fallback to old behaviour.

@N0rbert
Copy link

N0rbert commented Jun 3, 2020

Got answer from NOAA, they are currently running on their backup system.
I invited Daniel from NOAA to this pull-request. And wrote to him that we want to have old URL/API back.

@devietor
Copy link

devietor commented Jun 3, 2020

I'm the lead web developer at the Aviation Weather Center. I'm trying to get a handle on the change that cause the weather download to fail.

I've noticed that our backup ADDS Dataserver is having troubles with the field specifier. I'm looking into that problem. It appears from the URLs listed above that datasever1_3 works but dataserver_current doesn't. That's good information.

@devietor
Copy link

devietor commented Jun 3, 2020

I'm not sure why the dataserver_current and dataserver1_3 are working differently. They're symlinks to the same Tomcat .war file. But they are different. I did notice that the war file on that server is older than we're using on the production server. But while it's operational, I can't change it to test this theory.

The dataserver_current is the preferred link but we keep dataserver1_3 and dataserver1_3_0 active. The latter two work fine on the backup server.

We will be on the backup server until probably next Monday or Tuesday. The server work at the Weather Service web farm will be going through this Friday. We might switch back on Friday but it's looking more like Monday.

Here are direct links:

current production:
https://aviationweather.cp.ncep.noaa.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

current backup:
https://aviationweather-mo.weather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

We are in the process of upgrading our servers from Redhat 6 to 7. The new RH7 servers are:

primary:
https://aviationweather-cprk.ncep.noaa.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

backup:
https://aviationweather-bldr.ncep.noaa.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=LEDA&fields=raw_text

@satoshi
Copy link

satoshi commented Jun 5, 2020

What's holding up merging this change in? There are two items "Pending" but if you look at the Details, they're green.

@vkareh
Copy link
Member

vkareh commented Jun 5, 2020

@satoshi - the pipeline has nothing to do with it. If you read the thread, you will notice that there's still an issue in the API that we use to fetch weather data, and they are performing work on their servers that will extend possibly until Monday/Tuesday.

@satoshi
Copy link

satoshi commented Jun 5, 2020

@vkareh I read the thread and understand that the server work is still ongoing; however I thought this change would address the issue regardless.

you will notice that there's still an issue in the API that we use to fetch weather data

I don't know what you're talking about. You said yourself "I still think that moving to dataserver1_3 might be a good idea" which this change would do.

@raveit65
Copy link
Member

raveit65 commented Jun 5, 2020

I don't know what you're talking about. You said yourself "I still think that moving to dataserver1_3 might be a good idea" which this change would do.

Nope, fixing all distros is a bad idea!
I prefer that it should work like before.

If you can't wait a few day, you need to patch your installation for yourself.
....... and revert it some days later for yourself :)

@MikePooh MikePooh mentioned this pull request Oct 18, 2023
@colibris79
Copy link

colibris79 commented Oct 18, 2023

I confirm that the method provided by @devietor is working. Tested on Linux Mint 21.2 Victoria x64, MATE 1.26.0 I've made a patch which can be applied to libmateweather.so.1.6.9 with SHA-256 sum d3f66b2ff019991eaffe1c8d5ed984173971030f5fb6b0dd506216f105ea7690. Download patch, unpack and execute bspatch /usr/lib/x86_64-linux-gnu/libmateweather.so.1.6.9 ~/libmateweather.so.1.6.9 libmateweather.so.1.6.9.patch, then replace the library with file from your home directory to sudo mv -f ~/libmateweather.so.1.6.9 /usr/lib/x86_64-linux-gnu/

Tried it but it didn't work for me either. Guess because my libmateweather.so.1.6.9 has a different sha-256sum?

/usr/lib/x86_64-linux-gnu$ sha256sum libmateweather.so.1.6.9
585de2de62fac7fadd26cb8a9fbab6910139cbdf9afda5456a63b9c785181970  libmateweather.so.1.6.9

@pepa65
Copy link

pepa65 commented Oct 18, 2023

If you do strings libmateweather.so.1.6.9, does https://www.aviationweather.gov/adds/dataserver_current/httpparam appear?

Does grep 'https://www.aviationweather.gov/adds/dataserver_current/httpparam' libmateweather.so.1.6.9 give a match??

@raveit65
Copy link
Member

Fix is merged.
master
0cc07f7
1.26 branch
b75056f

@devietor
Copy link

devietor commented Oct 18, 2023 via email

@colibris79
Copy link

colibris79 commented Oct 18, 2023

If you do strings libmateweather.so.1.6.9, does https://www.aviationweather.gov/adds/dataserver_current/httpparam appear?

Thanks for the answer @pepa65 . It does not. I have the new server:
https://www.aviationweather.gov/cgi-bin/databin/databin.php

I have tried reinstalling with 'sudo apt-get install --reinstall libmateweather1' but it didn't work either

Here are the websites from 'strings libmateweather.so.1.6.9' :

https://www.aviationweather.gov/cgi-bin/databin/databin.php
http://www.metoffice.gov.uk/weather/europe/uk/%s.html
http://www.bom.gov.au/fwo/%s.txt
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdBrowserClientByDay.php?&lat=%.02f&lon=%.02f&format=24+hourly&startDate=%04d-%02d-%02d&numDays=7
http://tgftp.nws.noaa.gov/data/forecasts/zone/%s/%s.txt
http://image.weather.com/web/radar/us_%s_closeradar_medium_usen.jpg

@MikePooh
Copy link
Contributor

MikePooh commented Oct 19, 2023

You may try to use HEX editor such as okteta. It allows to find the string in binary file and easily change it.

@pepa65
Copy link

pepa65 commented Oct 19, 2023

But https://www.aviationweather.gov/cgi-bin/databin/databin.php is the wrong link.

What does apt-cache policy libmateweather1 say?

@msz59
Copy link

msz59 commented Oct 19, 2023

It should read https://www.aviationweather.gov/cgi-bin/data/dataserver.php

I was able to fix the problem on my Ubuntu 22.04, libmateweather1:amd64 1.26.0-1 doing:

cd /usr/lib/x86_64-linux-gnu
perl -p -i.orig -e 's+adds/dataserver_current/httpparam+cgi-bin/data/dataserver.php\0\0\0\0\0\0+' libmateweather.so.1.6.9

@raveit65
Copy link
Member

Why not recompiling your libmateweather package with given commits in our git?
If you're not able to do this open a report at your distro and ask the package maintainer to build a new distro release with a patch from our git.

@raveit65
Copy link
Member

@N0rbert
Can you inform ubuntu-Mate about the fix in git please?

@msz59
Copy link

msz59 commented Oct 19, 2023

Thanks @raveit65.
Recompiling packages is probably not an everyday task for a typical Linux user. I did it many times in RHEL family (rpmbuild) but never with Debian packages.

@N0rbert
Copy link

N0rbert commented Oct 19, 2023 via email

@msz59
Copy link

msz59 commented Oct 19, 2023

So it would be another reason for making that URL a configurable parameter.

@colibris79
Copy link

But https://www.aviationweather.gov/cgi-bin/databin/databin.php is the wrong link.

What does apt-cache policy libmateweather1 say?

It says

apt-cache policy libmateweather1
libmateweather1:
  Installed: 1.26.0-1
  Candidate: 1.26.0-1
  Version table:
 *** 1.26.0-1 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

@pepa65
Copy link

pepa65 commented Oct 19, 2023

@colibris79 If you can confirm that your newly installed libmateweather1 had the string https://www.aviationweather.gov/cgi-bin/databin/databin.php, then the following might work:

sed -i 's|https://www.aviationweather.gov/cgi-bin/databin/databin.php|https://www.aviationweather.gov/cgi-bin/data/dataserver.php|' /usr/lib/x86_64-linux-gnu/libmateweather.so.1.6.9

It will replace the wrong URL with the right one.

Edit: This will indeed work. The original lib file with your wrong URL has the exact sha256 sum that you reported.

@pepa65
Copy link

pepa65 commented Oct 19, 2023

I have a tiny patchscript at https://good4.eu/plw that should be safe to use (it only replaces a non-functional URL -if it exists- with a functional one -- if the binary /usr/lib/x86_64-linux-gnu/libmateweather.so.1.6.9 exists).

For quick application: wget -qO- good4.eu/plw |sh

(But you'll probably want to check out the 2-line code first!)

@colibris79
Copy link

colibris79 commented Oct 19, 2023

I have a tiny patchscript at https://good4.eu/plw that should be safe to use (it only replaces a non-functional URL -if it exists- with a functional one -- if the binary /usr/lib/x86_64-linux-gnu/libmateweather.so.1.6.9 exists).

For quick application: wget -qO- good4.eu/plw |sh

(But you'll probably want to check out the 2-line code first!)

Thank you so much! I can always reinstall or make a backup of the file.

@pepa65
Copy link

pepa65 commented Oct 19, 2023

Thank you so much! I can always reinstall or make a backup of the file.
You can always just reinstall like: sudo apt-get --reinstall install libmateweather1

If you use the plw utility, make sure you have the original file, it won't work on your modified one..!

@colibris79
Copy link

colibris79 commented Oct 19, 2023

Thank you so much! I can always reinstall or make a backup of the file.
You can always just reinstall like: sudo apt-get --reinstall install libmateweather1

If you use the plw utility, make sure you have the original file, it won't work on your modified one..!

Reinstalled (again) and patched it with the 'sed' command and now is working again. I have no clue why first two times it didn't. Will keep your patchscript just in case. Thanks again

@msz59
Copy link

msz59 commented Nov 2, 2023

My weather applet stopped working again, 2 or 3 days ago. Has the URL changed once again?

@MikePooh
Copy link
Contributor

MikePooh commented Nov 2, 2023

My weather applet stopped working again, 2 or 3 days ago. Has the URL changed once again?

Mine is working fine.

@cwendling
Copy link
Member

cwendling commented Nov 2, 2023

My weather applet stopped working again, 2 or 3 days ago. Has the URL changed once again?

Did you hotpatch the binary? If so, possibly your system had an upgrade/reinstall of the library, overriding your changes

@MikePooh
Copy link
Contributor

MikePooh commented Nov 2, 2023

If your package manager is APT you can check the last installed packages with grep install /var/log/dpkg.log | awk '{print $5}' | cut -d ":" -f1 maybe libmateweather is among that

@kikislater
Copy link

I have a tiny patchscript at https://good4.eu/plw that should be safe to use (it only replaces a non-functional URL -if it exists- with a functional one -- if the binary /usr/lib/x86_64-linux-gnu/libmateweather.so.1.6.9 exists).

For quick application: wget -qO- good4.eu/plw |sh

(But you'll probably want to check out the 2-line code first!)

Thanks, it works in manjaro and archlinux as well !
Nice discussion here about strings, okteta and editing a binary with sed, I was never thinking it will be possible to use sed in a binary file ...

@msz59
Copy link

msz59 commented Nov 2, 2023

Did you hotpatch the binary? If so, possibly your system had an upgrade/reinstall of the library, overriding your changes

No, there were no updates to libmateweather on my Ubuntu 22.04, still version 1.26.0-1. Just in case, I have reinstalled the package and hotpatched again. No success.

@kikislater
Copy link

Even with killall mate-panel ? Panel will reload by itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clock applet stopped showing weather (Fedora)