Urgent.News

What's breaking now, across hundreds of outlets.

Tech

jq --arg vs --argjson: keep build ID 001 from turning into 1

The shell hands a release job two strings: the build ID 001 and the dry-run setting false . The manifest needs to keep the first as text and turn the second into a boolean. Use --arg for the ID and --argjson for the trusted boolean literal. With jq 1.7, jq -n --argjson id 001 '$id' printed 1 on my machine. JSON numbers do not allow leading zeros, so don't rely on another parser accepting that…

The release job is given two strings: the build ID "001" and the dry-run setting "false". The manifest requires keeping the first as text and turning the second into a boolean. The --arg flag is used for the build ID and --argjson for the dry-run flag. Starting with jq 1.7, the command jq -n --argjson id 001 '$id' printed "1" instead of "001", as JSON numbers cannot have leading zeros.

This discrepancy can lead to errors if the wrong type is used for a field with different implications. For instance, treating the ID as a small integer changes the name of the artifact, while treating the dry-run flag as a boolean decides whether to write a report or deploy. The minimal example using jq -n --arg id "$build_id" --argjson dry "$dry_run" '{build_id: $id, dry_run: $dry}' shows that the ID is printed as a string while the dry-run flag is printed as the JSON literal "false".

When a shell variable containing "false" is passed as --arg, it becomes a JSON string and selects the wrong branch. This issue is not caused by Bash's test behavior but by jq's handling of JSON inputs. To avoid confusion, the type of each field should be decided before choosing the flags. If the output fields are known, the flags can be chosen accordingly.

For instance, the build ID is a label and must be kept as text, while the dry-run flag is a decision and must be a boolean. In the manifest, the build ID is a policy field from "0" to "10", and a test must be run with "false" to ensure the correct branch is selected. The contract for the input should be checked separately for each field, and values that could be misinterpreted should be rejected.

The final JSON file should be checked to ensure it meets the expected format and type for each field.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

See today's edition · More options

More in Tech

The booking was saved, but the customer saw an error: email after commit in Next.js

This bug made it into the released versions of my Next.js 15 templates (two booking sites, a barbershop and a dental clinic, and two small online stores). All the tests were green.

  • Duplicate bookings occurred due to email failure after form submission in Next.js 15 templates.
  • Email sending function sendMail modified to return false instead of throwing exception.
  • UI updated to display correct email status, informing users of confirmation email delivery.

A Chart Is Four Systems in a Trench Coat

A Chart Is Four Systems in a Trench Coat go-pptx Tech Blog · Part 5: The Chart Subsystem — From Restricted Types to Combo Charts and Embedded Workbooks Series: go-pptx Tech Blog (10 parts) Baseline…

  • Altering one layer causes inconsistencies when opening the chart in PowerPoint
  • Go-pptx treats chart as restricted subsystem with explicit contract between Input and Output

Auto-Narration Without FFmpeg

Auto-Narration Without FFmpeg go-pptx Tech Blog · Part 6: Media, Playback Timing, and Auto-Narration — A Pure Go Approach Without FFmpeg Series: go-pptx Tech Blog (10 parts) Baseline: v2.4.4 Keywords…

  • Auto-narration achieved via pure Go without FFmpeg
  • WAV files analyzed by reading fmt block details
  • MP4 and WebM durations marked as DurationUnknown

More from Sunday, 6 December 2026 →