Bug #16306

Hammer should validate that --id options aren't blank

Added by Perry Gagne 12 months ago. Updated 12 months ago.

Status:New
Priority:Normal
Assigned To:-
Category:Hammer core
Target version:Foreman - Team Marek backlog
Difficulty: Bugzilla link:
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

This is the error printed when an deleting an architecture and giving it an id that does not exist

[root@host ~]# hammer -u admin  architecture delete --id="-1" 
Could not delete the architecture:
  Resource architecture not found by id '-1'

However, it seems when an empty string is used it prints a HTTP error

[root@host ~]# hammer -u admin  architecture delete --id="" 
Could not delete the architecture:
  404 Resource Not Found

History

#1 Updated by Perry Gagne 12 months ago

I think the fix here for it do to print a message that indicates the id is invalid or does not exist.

#2 Updated by Tomáš Strachota 12 months ago

  • Subject changed from "404 Resource Not Found" printed while doing deleting architecture with id "" to Hammer should validate that --id options aren't blank
  • Target version set to Team Marek backlog

The messages appear inconsistent. They're different because it's two types of failures. In the first case hammer tries to fetch non-existent resource form the server, it get correct response and prints the message. In the second case hammer passes blank id for building the url and hits DELETE /architectures/ that doesn't exist. So from the server's point of view the response is correct too but hammer could detect that much earlier because it doesn't make sense to use blank id. Also other commands suffer from this issue:

> hammer host delete --id="" 
Could not delete the host:
  404 Resource Not Found

Therefore the correct fix should be adding a validation for all --id options and checking for non-blank values. I'm changing the subject to make the issue more generic.

Also available in: Atom PDF