errbit custom notification backtrace - airbrake

I'm sending a custom notification to Errbit using Airbrake.notify method. I want to pass the backtrace, which is already formatted in proper errbit-ready way, for example:
[{"function"=>"getAttr", "file"=>"[PROJECT_ROOT]/assets/backbone.stickit.js?body=1:285", "line"=>"29"},
{"function"=>"Stickit.ViewMixin.addBinding", "file"=>"[PROJECT_ROOT]/assets/backbone.stickit.js?body=1:197", "line"=>"26"},
{"function"=>"Stickit.ViewMixin.addBinding/<", "file"=>"[PROJECT_ROOT]/assets/backbone.stickit.js?body=1:122", "line"=>"11"}]
Currently I'm parsing the array to make a string of it and pass it to Airbrake.notify as :backtrace option, but is it possible to somehow pass the whole array without parsing?

Related

How to parse the string content of debugDescription in XCUITest swift

As debugDescription returns the XCUIElement UI Tree and this if of type String.
Want to fetch specific information based upon parameters like label :[String] will return all the label values, find_Application - will return the bundleID etc
You can use element.snapshot().dictionaryRepresentation which gives a parsed version of output of element.debugDescription or element.snapshotDescription.
You can use element.snapshot().children to get the child element's snapshots iteratively if you want to create your own parser.

TYPO3 Fluid Form returns old values

Am running a form using fluid with two fields, username and password. When first run, correct data is sent to the action. When different data is resubmitted, original data is sent to the controller action instead of the new values. How do I solve this problem?
EDIT: I've discovered that an array containing the user-submitted form fields and their values are obtained from the request, serialized as is and the string stored in a hidden input field called '__referrer[arguments]', which is then submitted with the form back to the user. When the user resubmits the form again with new values, the user doesn't realize that the old values are in the form, in the form of a serialized string, which is submitted together with the new values. Turns out, this is ok if no errors are reported by the validators. In that case the data is simply passed to the controller action and processing continues. But if errors are collected, processing is not sent to the controller action but is sent to the error action. The error action unserializes the old data and forwards that data (instead of the the new values) to the intended action controller. See \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::forwardToReferringRequest().
EDIT: Steps to reproduce;
Create an action with one argument and create a form with one input element and a submit button. Create a validator for the element. Make it a string property. When all is said and done, start by sending a VALID value and let the form return. it will come back with no errors. but also if you look at it's hidden values, you find that the __referrer[arguments] has changes. That's because your previous values were serialized and are there. Now submit an INVALID value and check values entering your action. You'll be stunned they are the old ones.
This is weird. Currently if I disable the production of the __referrer[arguments] input field in the \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::renderHiddenReferrerFields() method, everything works properly. How do I solve this? Please help.
Where things go wrong:
Here: \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::forwardToReferringRequest() . In this method, arguments are sought from __referrer internal arguments instead of the submitted values. Normally, if errors are found, only two elements are found in the arguments form variable: controller for controller name and action for action name. This is because they were submitted originally with the form and they will recycle without changing as long as the validator finds errors. Nothing else will be added to it. This is good... until it validates. When it validates, results are sent directly to the action controller and not through the error controller. When the process goes back to the form, the object or arguments submitted will be added to the form and returned to the user. Remember it validated. When you then send a wrong value next, it goes to the error controller, but the old values (that validated) and were serialized in the __referrer[arguments] are unserialized and forwarded to your action. And that's how you end up with old values in your action. This is because it assumes that the variable carries only two values inside it; the controller and action names only. It's wrong.
Assumption:
Form post values processing seem to be built under the presumption that once a form validates, you won't need it again.
News.
The values you send are sought from extbase arguments and serialized in \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::renderHiddenReferrerFields() method, added to the form just before presenting it to you. All TYPO3 has to do is skip your values and let the default values only be serialized. Just saw that the doc section of the function has this:
/**
* Renders hidden form fields for referrer information about
* the current controller and action.
*
* #return string Hidden fields with referrer information
* #todo filter out referrer information that is equal to the target (e.g. same packageKey)
*/
The #todo part is the news. Hope it's done in the next-patch since there are many scenarios where you want to resume the form such as in data entry.
Solution
Easiest solution: Initialize the empty argument in your action and hand the argument to the form. In my case, I use a DTO.
Example
public function accountLoginAction(DTO\Account\LoginDTO $accountLogin=null):ResponseInterface
{
if($accountLogin){
$this->repository->logon();
...
} else{
$accountLogin=DTO\Account\LoginDTO::getNewInstance();
}
$this->view->assign('object', $accountLogin);
return $this->response();
}
Hope it helps someone.

How to Send a Glympse from the Automate App

From the app Automate, I would like to send a Glympse. Automate's App Start block takes the following inputs. I assume not all of them have to be specified.
Package
Activity Class
Action
Data URI
Mime Type
Category
Extras
Flags
What should I set for the above values?
I am reading some code and looking at some documentation. I figured out that the Package should be com.glympse.android.glympse and the Activity Class should be com.glympse.android.intent.Create. The extras input should be set to a dictionary object. The dictionary should have a message key with a string value. The duration key has a long value which holds the number of milliseconds to share the location. I haven't figured out the rest of the keys or their formats.
Here are the steps...
Create a dictionary named recipient with these keys:
type with a string value of sms
address with a string value of 5425551212 // replace with the actual phone number
Create another dictionary named options with these keys:
recipients with a string value of jsonEncode(recipient) // this will convert the recipient dictionary into a JSON string
message with a string value of whatever you want to say
duration with a long value of the number of milliseconds to share the Glympse location (e.g. 1800000 for 30 minutes)
Use the App Start block with the following inputs:
Package is set to com.glympse.android.glympse
Activity Class is set to com.glympse.android.intent.Create
Action is set to Run
Extras is set to options // the dictionary created above
This will cause the Glympse screen to show up so that the user only has to hit the Create button.

Check for list of String in DataAnnotation

I need to check whether the Property contains one of the or all following strings
"C-I", "C-II", "C-III", "C-IV", "C-V"
if not it Errormessage must be
"Invalid Property. Must be blank or C-I, C-II, C-III, C-IV, or C-V.",
i don know which "DataAnnotation Attribute" to use and How? if possible please provide sample.
You could use the Regular Expression data annotation. However, I would recommend implementing IValidatableObject on your data class. You can then write your custom logic within the Validate method. This way, if/when those valid options change, you would just be modifying a collection, rather then trying to figure out a new valid regex statement.
It can be done using anyone of the follwing Attributes
**
1.EnumDataTypeAttribute
2.CustomValidationAttribute
3. Creating New Custom Attribute.
**

Get statuscode text in C#

I'm using a plugin and want to perform an action based on the records statuscode value. I've seen online that you can use entity.FormattedValues["statuscode"] to get values from option sets but when try it I get an error saying "The given key was not present in the dictionary".
I know this can happen when the plugin cant find the change for the field you're looking for, but i've already checked that this does exist using entity.Contains("statuscode") and it passes by that fine but still hits this error.
Can anyone help me figure out why its failing?
Thanks
I've not seen the entity.FormattedValues before.
I usually use the entity.Attributes, e.g. entity.Attributes["statuscode"].
MSDN
Edit
Crm wraps many of the values in objects which hold additional information, in this case statuscode uses the OptionSetValue, so to get the value you need to:
((OptionSetValue)entity.Attributes["statuscode"]).Value
This will return a number, as this is the underlying value in Crm.
If you open up the customisation options in Crm, you will usually (some system fields are locked down) be able to see the label and value for each option.
If you need the label, you could either do some hardcoding based on the information in Crm.
Or you could retrieve it from the metadata services as described here.
To avoid your error, you need to check the collection you wish to use (rather than the Attributes collection):
if (entity.FormattedValues.Contains("statuscode")){
var myStatusCode = entity.FormattedValues["statuscode"];
}
However although the SDK fails to confirm this, I suspect that FormattedValues are only ever present for numeric or currency attributes. (Part-speculation on my part though).
entity.FormattedValues work only for string display value.
For example you have an optionset with display names as 1, 2, 3,
The above statement do not recognize these values because those are integers. If You have seen the exact defintion of formatted values in the below link
http://msdn.microsoft.com/en-in/library/microsoft.xrm.sdk.formattedvaluecollection.aspx
you will find this statement is valid for only string display values. If you try to use this statement with Integer values it will throw key not found in dictionary exception.
So try to avoid this statement for retrieving integer display name optionset in your code.
Try this
string Title = (bool)entity.Attributes.Contains("title") ? entity.FormattedValues["title"].ToString() : "";
When you are talking about Option set, you have value and label. What this will give you is the label. '?' will make sure that the null value is never passed.