View Issue Details

IDProjectCategoryView StatusLast Update
408RackTablesdefaultpublic2012-09-02 15:57
Reporteruser186Assigned Toinfrastation  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.18.6 
Target Version0.20.0Fixed in Version0.20.0 
Summary408: "Argument 'vs_id' of value '' is invalid (parameter is missing)" error message when you try to add RS pool
Descriptionfollowing error when clicking on ADD button in RS pool tab.

SVN:
Argument 'vs_id' of value '' is invalid (parameter is missing).

0.18.6:
Assertion failed: Request parameter 'vs_id' of value 'NULL' is invalid. (parameter is missing)

I don't have RS pool define.
TagsNo tags attached.

Activities

infrastation

infrastation

2011-02-28 18:57

administrator   ~0000278

You see the message, because no virtual services exist in the database. The matter is, "RS pool" tab should be just hidden in such a case. That is the only real bug here.

user186

2011-03-01 13:44

  ~0000280

Yes, your are right and it's not high priority.
infrastation

infrastation

2011-03-01 13:59

administrator   ~0000281

I'm leaving this "acknowledged" to be fixed later.

2012-03-12 09:12

 

0001-The-new-SLB-item-form-now-gives-a-notice-when-one-of.patch (3,577 bytes)   
From ead76d0fefe02d86910a0a59754d03faa3a8e3ab Mon Sep 17 00:00:00 2001
From: Hannes Georg <hannes.georg@xing.com>
Date: Mon, 12 Mar 2012 09:41:30 +0100
Subject: [PATCH] The new SLB item form now gives a notice when one of the
 realms is emtpy

---
 wwwroot/inc/slb-interface.php |   44 +++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/wwwroot/inc/slb-interface.php b/wwwroot/inc/slb-interface.php
index 988917f..3bf2e25 100644
--- a/wwwroot/inc/slb-interface.php
+++ b/wwwroot/inc/slb-interface.php
@@ -63,34 +63,58 @@ function renderSLBEditTab ($entity_id)
 // realms 1 and 2 are realms to draw inputs for
 function renderNewSLBItemForm ($realm1, $realm2)
 {
-	function print_realm_select_input($realm)
+	/**
+	 * Returns a list of values, a human readable name and options
+	 * for the selecttag for a given realm.
+	 */
+	function get_realm_data($realm)
 	{
+		$name = null;
+		$list = array();
+		$options = array();
 		switch ($realm)
 		{
 			case 'object':
-				echo "<tr valign=top><th class=tdright>Load balancer</th><td class=tdleft>";
-				printSelect (getNarrowObjectList ('IPV4LB_LISTSRC'), array ('name' => 'object_id', 'tabindex' => 100));
+				$name = 'Load balancer';
+				$list = getNarrowObjectList ('IPV4LB_LISTSRC');
+				$options = array ('name' => 'object_id', 'tabindex' => 100);
 				break;
 			case 'ipv4vs':
-				echo '</td></tr><tr><th class=tdright>Virtual service</th><td class=tdleft>';
-				printSelect (getIPv4VSOptions(), array ('name' => 'vs_id', 'tabindex' => 101));
+				$name = 'Virtual service';
+				$list = getIPv4VSOptions();
+				$options =	array ('name' => 'vs_id', 'tabindex' => 101);
 				break;
 			case 'ipv4rspool':
-				echo '</td></tr><tr><th class=tdright>RS pool</th><td class=tdleft>';
-				printSelect (getIPv4RSPoolOptions(), array ('name' => 'pool_id', 'tabindex' => 102));
+				$name = 'RS pool';
+				$list = getIPv4RSPoolOptions();
+				$options = array ('name' => 'pool_id', 'tabindex' => 102);
 				break;
 			default:
 				throw new InvalidArgException('realm', $realm);
 		}
+		return array('name'=>$name, 'list'=>$list, 'options'=> $options);
 	}
 
+	$realm1_data = get_realm_data($realm1);
+	$realm2_data = get_realm_data($realm2);
 	startPortlet ('Add new');
 	echo "<table cellspacing=0 cellpadding=5 align=center>";
 	printOpFormIntro ('addLB');
-	print_realm_select_input($realm1);
+	echo "<tr valign=top><th class=tdright>{$realm1_data['name']}</th><td class=tdleft>";
+	printSelect ($realm1_data['list'], $realm1_data['options']);
 	echo '</td><td class=tdcenter valign=middle rowspan=2>';
-	printImageHREF ('ADD', 'Configure LB', TRUE, 120);
-	print_realm_select_input($realm2);
+	if( $realm1_data['list'] && $realm1_data['list'] ){
+		printImageHREF ('ADD', 'Configure LB', TRUE, 120);
+	}else{
+		$names = array();
+		if( !$realm1_data['list'] ) $names[]= 'a '.$realm1_data['name'];
+		if( !$realm2_data['list'] ) $names[]= 'a '.$realm2_data['name'];
+		$message = 'Please create '.(join(' and ', $names)).'.';
+		showNotice($message);
+		printImageHREF ('DENIED', $message, FALSE);
+	}
+	echo "<tr valign=top><th class=tdright>{$realm2_data['name']}</th><td class=tdleft>";
+	printSelect ($realm2_data['list'], $realm2_data['options']);
 	echo "</td></tr>\n";
 	echo "<tr><th class=tdright>VS config</th><td colspan=2><textarea tabindex=110 name=vsconfig rows=10 cols=80></textarea></td></tr>";
 	echo "<tr><th class=tdright>RS config</th><td colspan=2><textarea tabindex=111 name=rsconfig rows=10 cols=80></textarea></td></tr>";
-- 
1.7.5.4

user292

2012-03-12 09:13

  ~0000626

Hi,
I created a patch which shows a notice if any of the selects is empty.
infrastation

infrastation

2012-03-13 12:10

administrator   ~0000627

I have studied the patch, it implements something different. Hannes, could you check the contents of triggers.php and prepare a different patch, which would disable respective tab, unless all the data it relies upon is present?
infrastation

infrastation

2012-09-02 15:57

administrator   ~0000773

After thoroughly reviewing the suggested patch and my own comment I resolve this issue with the following notes:

1. Addressing this issue through the tab trigger would indeed be more expensive than it looked initially due to building the SELECT OPTIONs.
2. The suggested patch is now merged into master branch (commit 2bb66f5) with a few justifications:
2.1. The check condition had $realm1_data checked twice.
2.2. Suppressing the submit control isn't enough, the <FORM> tag should be suppressed as well (otherwise the form is still submittable with Enter).
2.3. The current coding convention is using count() and implode() instead of array itself and join() respectively, as well as certain spacing/indentation/parentheses pattern.
3. This fix won't be backported to maintenance-0.19.x branch.


Thank you.

Issue History

Date Modified Username Field Change
2011-02-28 12:52 user186 New Issue
2011-02-28 18:54 infrastation Status new => assigned
2011-02-28 18:54 infrastation Assigned To => infrastation
2011-02-28 18:57 infrastation Note Added: 0000278
2011-03-01 13:44 user186 Note Added: 0000280
2011-03-01 13:59 infrastation Note Added: 0000281
2011-03-01 13:59 infrastation Assigned To infrastation =>
2011-03-01 13:59 infrastation Priority normal => low
2011-03-01 13:59 infrastation Status assigned => acknowledged
2011-03-01 13:59 infrastation Product Version 0.19.1 =>
2012-03-12 09:12 user292 File Added: 0001-The-new-SLB-item-form-now-gives-a-notice-when-one-of.patch
2012-03-12 09:13 user292 Note Added: 0000626
2012-03-13 12:10 infrastation Note Added: 0000627
2012-09-01 23:17 infrastation Assigned To => infrastation
2012-09-01 23:17 infrastation Status acknowledged => assigned
2012-09-02 15:57 infrastation Note Added: 0000773
2012-09-02 15:57 infrastation Status assigned => closed
2012-09-02 15:57 infrastation Resolution open => fixed
2012-09-02 15:57 infrastation Product Version => 0.18.6
2012-09-02 15:57 infrastation Fixed in Version => 0.20.0
2012-09-02 15:57 infrastation Target Version => 0.20.0