Script stopped working #1

Open
opened 2022-09-08 12:44:18 +02:00 by lio · 2 comments

parse error: Invalid numeric literal at line 1, column 6

parse error: Invalid numeric literal at line 1, column 6

I got a similar error:

parse error: Invalid numeric literal at line 1, column 4

Note that the error was raised after php: command not found, mentioned in #3.
This might indicate that the parse error actually occured after line 233.

I got a similar error: ```bash parse error: Invalid numeric literal at line 1, column 4 ``` Note that the error was raised after `php: command not found`, mentioned in #3. This might indicate that the parse error actually occured after line 233.

After some debugging, I think this was simply a consequence of user error in ponsapi.config.

I mistakenly specified PONS_DICT="slen" instead of PONS_DICT="ensl".
This made curl -s --header "X-Secret: $PONS_SECRET" $PONS_URI$PONS_QUERY return Not found, which in turn led PONS_JSON to get assigned "Not found". With this, the error which happens in line 250 can be reproduced:

$ echo $PONS_FILTER
[.[] | {"language_p": .lang, "hits_p": [.hits[] | .roms | .[] | {"headword_p": .headword, "wordclass_p": .wordclass, "arabs_p": [ .arabs | .[] | {"header_p": .header, "translations_p": [.translations[] | {"source_p": .source, "target_p": .target }] } ] }] }]
$ echo "Not found" | jq "$PONS_FILTER"
parse error: Invalid numeric literal at line 1, column 4

After fixing the config file, the script works as expected.

You could handle the edge case of PONS_JSON being "Not found" or instruct the users to carefully write their config.

After some debugging, I think this was simply a consequence of user error in `ponsapi.config`. I mistakenly specified `PONS_DICT="slen"` instead of `PONS_DICT="ensl"`. This made `curl -s --header "X-Secret: $PONS_SECRET" $PONS_URI$PONS_QUERY` return `Not found`, which in turn led `PONS_JSON` to get assigned "Not found". With this, the error which happens in [line 250](https://git.kompot.si/lio/PonsapiCli/src/branch/master/trans.sh?plain=1#L250) can be reproduced: ```console $ echo $PONS_FILTER [.[] | {"language_p": .lang, "hits_p": [.hits[] | .roms | .[] | {"headword_p": .headword, "wordclass_p": .wordclass, "arabs_p": [ .arabs | .[] | {"header_p": .header, "translations_p": [.translations[] | {"source_p": .source, "target_p": .target }] } ] }] }] $ echo "Not found" | jq "$PONS_FILTER" parse error: Invalid numeric literal at line 1, column 4 ``` After fixing the config file, the script works as expected. You could handle the edge case of `PONS_JSON` being "Not found" or instruct the users to carefully write their config.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lio/PonsapiCli#1
There is no content yet.