Getting the error Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']', got 'undefined' - database

"Name": "Python",
"Description": "Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn't specialized for any specific problems.",
"concepts": ['63c8ed27ee5c3450a57e1568', '63c8f44c807abb9bccdfcbf4', '63c8f44c807abb9bccdfcbf5', '63c8f44c807abb9bccdfcbf6', '63c8f44c807abb9bccdfcbf7' ]
}
Error: Parse error on line 4:
...ms.", "concepts": ['63c8ed27ee5c3450a57
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']', got 'undefined'
What is exactly to be changed in the above JSON document in order to solve the error?

Related

How can I validate an XML with String arrays using a RAML DataType?

I'm having an issue where a simple string array or integer array creates a warning and prevents the validation of XMLs within my RAML API specification in Anypoint Platform.
These are the files I'm currently using:
customerNames.raml:
#%RAML 1.0 DataType
displayName: customerNames
description: Full detail view on a customerNames array
additionalProperties: false
properties:
customerName:
type: array
items: string
customerNames.xml:
<?xml version="1.0" encoding="UTF-8"?>
<customerNames>
<customerName>John Doe</customerName>
<customerName>Jane Doe</customerName>
</customerNames>
Validation results in the following warning:
validation error
I've tried other notations as well:
#%RAML 1.0 DataType
displayName: customerNames
description: Full detail view on a customerNames array
additionalProperties: false
properties:
customerName:
type: string[]
But to no avail.
When I try to recreate this issue using JSON files, both notations do not yield the warning and validation can happen as expected.
Is this an Anypoint Platform bug or is my syntax incorrect?

How can I fix this Rails minitest & Capybara mailer testing ActionView::Template host error?

I'm trying to test mailers in some system tests. I'm using Ruby 3.0.2, Rails 6.1.4, Capybara 3.26, Selenium-webdriver and I'm writing tests in Minitest. The below tests fails when it gets to the assert_equal ['dave#example.com'], mail.to line:
orders_test.rb:
test "check full payment with cheque flow" do
LineItem.delete_all
Order.delete_all
visit store_index_url
click_on 'Add to cart', match: :first
click_on 'Checkout'
fill_in 'order_name', with: 'Dave Thomas'
fill_in 'order_address', with: '123 Main Street'
fill_in 'order_email', with: 'dave#example.com'
assert_no_selector "#order_routing_number"
select 'Cheque', from: 'Pay type'
fill_in 'Routing #', with: '123456'
fill_in 'Account #', with: '678901'
assert_selector "#order_routing_number"
assert_selector "#order_account_number"
perform_enqueued_jobs do
click_button 'Place order'
end
orders = Order.all
assert_equal 1, orders.size
order = orders.first
assert_equal 'Dave Thomas', order.name
assert_equal '123 Main Street', order.address
assert_equal 'dave#example.com', order.email
assert_equal 'Cheque', order.pay_type
assert_equal 1, order.line_items.size
mail = ActionMailer::Base.deliveries.last
assert_equal ['dave#example.com'], mail.to
assert_equal 'James Kemp<from#example.com>', mail[:from].value
assert_equal 'Order received; thanks', mail.subject
end
With the following error:
Error:
OrdersTest#test_check_full_payment_with_cheque_flow:
NoMethodError: undefined method `to' for nil:NilClass
test/system/orders_test.rb:62:in `block in <class:OrdersTest>'
Error:
OrdersTest#test_check_full_payment_with_cheque_flow:
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
Reading error message suggestion and googling others' solutions suggests to put config.action_mailer.default_url_options = { :host => 'www.example.com' } in config/environments/test. When I put this line in it then throws an error from the same assert_equal ... mail.to line as the above error throws this error:
Error:
OrdersTest#test_check_full_payment_with_cheque_flow:
DRb::DRbRemoteError: undefined method `to' for nil:NilClass (NoMethodError)
test/system/orders_test.rb:62:in `block in <class:OrdersTest>'
Error:
OrdersTest#test_check_full_payment_with_cheque_flow:
DRb::DRbRemoteError: No route matches {:action=>"show", :controller=>"line_items", :locale=>#<LineItem id: 1, product_id: 298486374, cart_id: nil, created_at: "2021-11-07 16:53:19.133389000 +0000", updated_at: "2021-11-07 16:53:19.966253000 +0000", quantity: 1, order_id: 980190963>}, missing required keys: [:id]
Did you mean? line_items_url
line_item_path
line_items_path
edit_line_item_url (ActionView::Template::Error)
app/views/line_items/_line_item.html.erb:13
The code works fine in development mode, without any default_url_options explicitly specified in config anywhere.
Can anyone advise what the issue is here and how I should correct it?
(FYI - This is from the Agile Web Development with Rail 6 tutorial, ch.17.)
You are being told that the to method is getting called on a nil, so mail is nil. Hence there is no mail in the deliveries array.
The reason this would be occurring is that when using a Javascript driver, the Capybara tests and the Rails server run in different processes and communicate asynchronously. Hence they will each have a different deliveries array, and you cannot check emails this way.
Normally you stick to the contents of the webpage when using Capybara. You can check the database if you like, because the tests and server communicate through the database, and Capybara maintains two connections to the same database, however even there if you use database transactions and such you can get into trouble.
However in general you can't check anything that isn't the webpage or database.
You might choose to check emails through unit or request/integration tests instead, or look for a solution like the capybara-email gem if you wish to do it in a system/feature test, which does add that functionality, although I haven't used it in a while and I'm not sure how up to date it is.

Apache Zeppelin: interpreter.json keeps getting reset

I'm trying to change the default interpreter in an interpreter group.
Specifically, I'm changing
"defaultInterpreter": true,
to
"defaultInterpreter": false,
in
{
"name": "spark",
"class": "org.apache.zeppelin.spark.SparkInterpreter",
"defaultInterpreter": true,
"editor": {
"language": "scala",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
}
},
Then changing the next section (Spark SQL) to true.
But then as I restart Zeppelin, interpreter.json gets reverted.
Please advice
Ok after digging around I think I found the right place.
In interpreters/< interpreter >/interpreter-settings.json is the actual place to edit the settings.
conf/interpreter.json is generated.
I wish these things were easily found in docs or via search though, not by developers digging and trying different things.

JSON-LD: 'Syntax error: value, object or array expected.'

I am getting the "value, object or array expected." syntax error when I test my JSON-LD code with Google's Structured Data Testing Tool. The error appears on line 143 of my code.
I am implementing Schema.org for a local business website with JSON-LD. I have
tried replacing the [ brackets with } brackets for the image object, and
even tried removing the comma on line 143. I either get the same error, or new errors appear. I have searched other problems related to this error, but they both had different code.
{
"#context": "https://schema.org",
"#type": "LocalBusiness",
"image": [
"http://secureservercdn.net/166.62.110.232/kkk.bd6.myftpupload.com/wp-
content/uploads/2019/05/360webclicks-logo2-4.fw_.png",
],
Highlighted error in the SDTT:
The last value must not be followed by a comma.
So, this
"image": [
"image.png",
],
should be this
"image": [
"image.png"
],
If you only have one value, you could omit the array ([…]):
"image": "image.png",

Browser.manage().addCookie() returns error missing 'name'

When I am trying to set cookies in protractor, I am getting below error message:
Failed: invalid argument: missing 'name'
(Session info:chrome=61.0.3163.100)
I have used below different codes to set cookie in protractor. But none of them is working.
Case 1:
browser.get('http://localhost:8080');
browser.driver.manage().addCookie('test', 'test');
Case 2:
browser.get('http://localhost:8080');
protractor.browser.manage().addCookie({ 'name': 'test', 'value': 'test', 'path': '/', 'domain': 'localhost' });
Case 3:
browser.get('http://localhost:8080');
browser.manage().addCookie('test', 'test', '/', 'localhost');
I am running code with protractor version 5.2.
Can anyone help me out? Thanks in advance.
I got solution of my problem. Below code worked for me.
(browser.manage() as any).addCookie({ name: 'test', value: 'test', domain: 'localhost' });
browser.get('http://127.0.0.1:8000');
browser.manage().addCookie('test', 'test', '/', '127.0.0.1');
Issue is with using localhost, use 127.0.0.1 instead
Please read further with issue with protractor here
Prefer using browser.driver.get() over browser.get().
As far as browser.driver.get() returns a promise, you should take it into account:
browser.driver.get('http://' + domain + '/').then(() => {
browser.manage().addCookie({name: 'foo', value: 'boo'});
});
Also notice, in this case you don't need to pass domain value to addCookie because protractor will use the current domain by default. This will also solve an issue with localhost which Mohan Ram mentioned

Resources