Urgent.News

What's breaking now, across thousands of outlets.

Tech

Day 34: A Hook That Cannot Fail, and an Error Three Commands From Its Cause

Today's theme is failures that report themselves somewhere other than where they happened. A Git hook with the wrong permissions does nothing and says nothing. A heredoc with a trailing space produces an error about a missing zip file, three commands downstream. One Git task, one AWS task. Install a post-update hook that tags every push to master, then deploy a Python Lambda from the CLI. The…

Day 34's theme revolves around failures that are reported elsewhere than where they occurred. An example is a Git hook with incorrect permissions that fails to execute and provides no indication of the failure. Another example involves a heredoc with an extra trailing space, which creates an error about a missing zip file, three commands downstream from the initial issue.

The hook in question is a post-update hook that automatically generates a release tag every time a push is made to the master branch in the KodeKloud Engineer platform. The hook's script checks each ref that has been updated and, if it is the master branch, it generates a tag using the current date and the commit hash. To ensure idempotency, any error messages related to the tag generation are redirected to /dev/null.

However, it is important to note that post-update hooks run after the ref updates have already occurred, so they cannot reject bad pushes. Instead, pre-receive or update hooks should be used for such validation. Additionally, the script must have the execute bit set, otherwise it will be ignored silently. When a hook is required to run on the server rather than the client, it must be placed on the server directly.

The last lesson from the Git tasks is to verify the output of each command rather than simply relying on the exit code. For instance, after creating a Lambda function, it is crucial to use the wait function command to ensure the function is active and available for invocation.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Bitmask Calendars: How I Built Fast, Timezone-Safe Slot Availability in Flutter

Drivers Lesson lets a student pick a driving instructor, see which time slots are actually free, book one, and pay for it — with 3DS card verification in the loop.

  • Bitmask calendars enable fast, timezone-safe slot availability in Flutter apps.
  • Author implemented bitmask representation for 30-minute time slots using single integer.
  • Handling timezone differences by storing and comparing slots as UTC internally.

Stop Guessing What Your Code Change Will Break

Ever changed one function, thought it was a small edit, then spent the next hour tracing through five other files to figure out what broke? That's the problem I set out to fix.

  • Change Impact Analyzer is a Visual Studio Code extension
  • Parses Python files with tree-sitter and pylsp
  • Recommends fixes and updates affected code automatically

More from Tuesday 1 September →