diff --git a/salt/client/mixins.py b/salt/client/mixins.py index 29b6077661..6561e6dfba 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -384,7 +384,11 @@ class SyncClientMixin(object): # Initialize a context for executing the method. with tornado.stack_context.StackContext(self.functions.context_dict.clone): - data['return'] = self.functions[fun](*args, **kwargs) + func = self.functions[fun] + try: + data['return'] = func(*args, **kwargs) + except TypeError as exc: + data['return'] = '\nPassed invalid arguments: {0}\n\nUsage:\n{1}'.format(exc, func.__doc__) try: data['success'] = self.context.get('retcode', 0) == 0 except AttributeError: diff --git a/tests/integration/runners/test_cache.py b/tests/integration/runners/test_cache.py index 064e887b05..7c6d73761f 100644 --- a/tests/integration/runners/test_cache.py +++ b/tests/integration/runners/test_cache.py @@ -34,3 +34,15 @@ class ManageTest(ShellCase): ret = self.run_run_plus('cache.flush', bank='cachetest/runner', key='test_cache') ret = self.run_run_plus('cache.list', bank='cachetest/runner') self.assertNotIn('test_cache', ret['return']) + + def test_cache_invalid(self): + ''' + Store, list, fetch, then flush data + ''' + # Store the data + ret = self.run_run_plus( + 'cache.store', + ) + # Make sure we can see the new key + expected = 'Passed invalid arguments:' + self.assertIn(expected, ret['return']) diff --git a/tests/integration/runners/test_jobs.py b/tests/integration/runners/test_jobs.py index e9d6b19cf1..d63d0955f8 100644 --- a/tests/integration/runners/test_jobs.py +++ b/tests/integration/runners/test_jobs.py @@ -30,6 +30,14 @@ class ManageTest(ShellCase): self.assertEqual(ret['return'], {}) self.assertEqual(ret['out'], []) + def test_lookup_jid_invalid(self): + ''' + jobs.lookup_jid + ''' + ret = self.run_run_plus('jobs.lookup_jid') + expected = 'Passed invalid arguments:' + self.assertIn(expected, ret['return']) + @skipIf(True, 'to be re-enabled when #23623 is merged') def test_list_jobs(self): ''' diff --git a/tests/integration/runners/test_salt.py b/tests/integration/runners/test_salt.py index 37488f9a48..71683a8e25 100644 --- a/tests/integration/runners/test_salt.py +++ b/tests/integration/runners/test_salt.py @@ -25,3 +25,11 @@ class SaltRunnerTest(ShellCase): self.assertEqual(out_ret, 'True') self.assertTrue(return_ret) + + def test_salt_cmd_invalid(self): + ''' + test return values of salt.cmd invalid parameters + ''' + ret = self.run_run_plus('salt.cmd') + expected = 'Passed invalid arguments:' + self.assertIn(expected, ret['return'])