upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/how-to/migration-scripts/30-extract-parse-failures.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docs/how-to/migration-scripts/30-extract-parse-failures.sh')
-rwxr-xr-xdocs/how-to/migration-scripts/30-extract-parse-failures.sh34
1 files changed, 33 insertions, 1 deletions
diff --git a/docs/how-to/migration-scripts/30-extract-parse-failures.sh b/docs/how-to/migration-scripts/30-extract-parse-failures.sh
index bc2049a..410fcbc 100755
--- a/docs/how-to/migration-scripts/30-extract-parse-failures.sh
+++ b/docs/how-to/migration-scripts/30-extract-parse-failures.sh
@@ -65,6 +65,14 @@
65 65
66set -euo pipefail 66set -euo pipefail
67 67
68# Get script directory for sourcing helpers
69SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
70
71# Source the service validation helper
72if [[ -f "$SCRIPT_DIR/validate-service.sh" ]]; then
73 source "$SCRIPT_DIR/validate-service.sh"
74fi
75
68# Colors for output (disabled if not a terminal) 76# Colors for output (disabled if not a terminal)
69if [[ -t 1 ]]; then 77if [[ -t 1 ]]; then
70 RED='\033[0;31m' 78 RED='\033[0;31m'
@@ -188,11 +196,35 @@ main() {
188 esac 196 esac
189 done 197 done
190 198
191 # Validate service name 199 # Validate service name format
192 if [[ ! "$service" =~ \.service$ ]]; then 200 if [[ ! "$service" =~ \.service$ ]]; then
193 service="${service}.service" 201 service="${service}.service"
194 fi 202 fi
195 203
204 # Validate service is appropriate for structured logging
205 # This prevents the common mistake of using ngit-relay instead of ngit-grasp
206 if type validate_service_for_structured_logging &>/dev/null; then
207 # Use non-interactive mode if not a terminal, skip log check (we'll do our own)
208 local interactive="true"
209 [[ ! -t 0 ]] && interactive="false"
210
211 if ! validate_service_for_structured_logging "$service" "false" "$interactive"; then
212 log_error "Service validation failed. Use an ngit-grasp service for structured logging."
213 exit 1
214 fi
215 else
216 # Fallback validation if helper not available
217 if [[ "$service" == *"ngit-relay"* ]]; then
218 log_error "Service name appears to be ngit-relay: $service"
219 log_error "Structured logging ([PARSE_FAIL]) only exists in ngit-grasp services."
220 log_error "Please use the ngit-grasp archive service instead."
221 log_error ""
222 log_error "To find the correct service:"
223 log_error " systemctl list-units 'ngit-grasp*' --all"
224 exit 1
225 fi
226 fi
227
196 log_info "Extracting parse failures from systemd logs" 228 log_info "Extracting parse failures from systemd logs"
197 log_info "Service: $service" 229 log_info "Service: $service"
198 log_info "Output: $output_dir" 230 log_info "Output: $output_dir"