The null object does not have a method []= - dart-polymer

I'm trying to run this following example minus some differences in pubspect.yaml since it doesn't run out of the box. Namely reflections needs to be 0.2.0 instead of 0.1.4 as seen on the example link.
Everything compiles fine. However I get a runtime error. I traced it to the following file:
https://github.com/dart-lang/polymer-dart/blob/behaviors/lib/init.dart
On line 25 I get the following error in the Dartium browser:
The null object does not have a method '[]='.
NoSuchMethodError: method not found: '[]='
Receiver: null
Arguments: ["push", Closure: (List, Iterable) => dynamic]
#0 Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2 _setUpListMethods (package:polymer/init.dart:25:14)
#3 initPolymer.<initPolymer_async_body> (package:polymer/init.dart:17:3)
#4 _RootZone.runUnary (dart:async/zone.dart:1204)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:131)
#6 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:637)
#7 _Future._propagateToListeners (dart:async/future_impl.dart:667)
#8 _Future._completeWithValue (dart:async/future_impl.dart:477)
#9 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:528)
#10 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#11 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#12 _ScheduleImmediateHelper._handleMutation (dart:html:49308)
My pubspec.yaml
name: myproject
dependencies:
polymer: ^1.0.0-rc
web_components: ^0.12.0
browser: ^0.10.0
reflectable: ^0.2.0
transformers:
- reflectable:
entry_points:
- web/main.dart
environment:
sdk: ">=1.2.0 <2.0.0"
dependency_overrides:
polymer:
git:
ref: behaviors
url: https://github.com/dart-lang/polymer-dart.git
polymer_interop:
git:
ref: 0.2.0-dev
url: https://github.com/dart-lang/polymer_interop.git
pubspec.lock
# Generated by pub
# See http://pub.dartlang.org/doc/glossary.html#lockfile
packages:
analyzer:
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.26.4"
args:
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4+2"
async:
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
barback:
description:
name: barback
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.2+8"
boolean_selector:
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
browser:
description:
name: browser
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0+2"
charcode:
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
cli_util:
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
code_transformers:
description:
name: code_transformers
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
collection:
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
convert:
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
crypto:
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
csslib:
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.2"
dart_style:
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
glob:
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
html:
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2+2"
http_multi_server:
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
http_parser:
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
initialize:
description:
name: initialize
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+2"
logging:
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.3"
matcher:
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
mime:
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.3"
package_config:
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
path:
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.9"
plugin:
description:
name: plugin
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
polymer:
description:
ref: behaviors
resolved-ref: "46be7836f387a8a2868507baf61940e871519986"
url: "https://github.com/dart-lang/polymer-dart.git"
source: git
version: "0.17.0-dev"
polymer_interop:
description:
ref: "0.2.0-dev"
resolved-ref: cbef534ef5d0839beeeb63f7c25f502df7e79377
url: "https://github.com/dart-lang/polymer_interop.git"
source: git
version: "0.2.0"
pool:
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.4"
pub_semver:
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
reflectable:
description:
name: reflectable
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
shelf:
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.5+2"
shelf_static:
description:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
shelf_web_socket:
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
source_map_stack_trace:
description:
name: source_map_stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
source_maps:
description:
name: source_maps
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.1+1"
source_span:
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.3"
stack_trace:
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.6"
stream_channel:
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
string_scanner:
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
test:
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.15+1"
typed_data:
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
unittest:
description:
name: unittest
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.6+4"
utf:
description:
name: utf
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0+3"
watcher:
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+2"
web_components:
description:
name: web_components
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+4"
web_socket_channel:
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
when:
description:
name: when
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
which:
description:
name: which
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
yaml:
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.10"
sdk: ">=1.17.0-dev.6.2 <1.20.0"
That's as far as I got. Again, all the other files are identical to that example.
Seems to be a dependency problem but I really don't know where to go from here to make the example run. Is it possible to fix this error? I know dart-polymer is still in RC but I'd think that simple example would run...
Update
Seems to fail on setUpListMethods() in polymer/init.dart because context variable array does not exist. I created a breakpoint and context is not found within the scope. Where is context declared? It still smells like a dependency problem.

If you use a recent Polymer 1.0.0-rc.x version you need to add the polymer transformer instead of the reflectable transformer
transformers:
- polymer:
entry_points:
- web/index.html
See also https://github.com/dart-lang/polymer-dart

Related

How to put data into request body intercepted on EnvoyFilter?

I'm trying this, but doesn't work and doesn't show any error.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: eva-decrypt-data
namespace: eva
spec:
configPatches:
- applyTo: HTTP_FILTER
match:
context: ANY
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
patch:
operation: INSERT_BEFORE
value:
name: envoy.lua
typed_config:
"#type": "type.googleapis.com/envoy.config.filter.http.lua.v2.Lua"
inlineCode: |
function envoy_on_request(request_handle)
local buffered = request_handle:body()
buffered:setBytes("new body data")
Posted community wiki based on comment for better visibility. Feel free to expand it.
The issue is solved. Function request_handle:body():setBytes("") works only on Istio version above 1.10:
The problem was istio version, request_handle:body():setBytes("") works only above 1.10

Openapi Springfox 3.0 examples

I have a yaml file which has examples for request body. but swagger-ui springfox generated json file generated by springfox doesn't show the request body example, which makes it to show schema example.
Any workaround for displaying request body examples?
#openapi #swagger-ui #springfox
openapi: 3.0.2
info:
title: Rule APIs
description: Rule APi
version: 1.0.0
contact:
email: abc#gmail.com
servers:
- url: 'https://{server}/v1/rule'
variables:
server:
default: localhost
security:
- BasicAuth: []
paths:
#####################################################################################################
############################ Rule APIs ###############################
#####################################################################################################
/rule-set:
parameters:
- $ref: '#/components/parameters/XRequestIdHeader'
post:
summary: Create a rule set.
description: Create a rule set.
operationId: createRule
tags:
- Rule
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RuleSet'
example:
name: My RuleSet
description: A new ruleSet
state: enabled
condition:
conditionType: ConditionAttributes
isNegate: false
dictionaryName: DEVICE
attributeName: attribute
operator: equals
attributeValue: attribute
serviceName: service
isProxy: false
responses:
'201':
$ref: '#/components/responses/BadRequest'
'400':
$ref: '#/components/responses/BadRequest'
json output

serverless framework with aws import function returns 404

I have two serverless app which are sharing the same custom authorizer. Suddenly the import function in the second serverless.yml file stopped working.
The app is based on https://github.com/medwig/serverless-shared-authorizer
gateway.serverless
service: authorizer-stack
provider:
name: aws
runtime: nodejs12.x
region: ap-south-1
profile: xxx-dev
functions:
authorizer:
handler: handler.auth
test:
handler: handler.privateEndpoint
events:
- http:
path: /api/test
method: get
authorizer:
type: CUSTOM
authorizerId:
Ref: Authorizer
test2:
handler: handler.publicEndpoint
events:
- http:
path: /api/test/public
method: get
resources:
Resources:
AuthorizerPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Fn::GetAtt: AuthorizerLambdaFunction.Arn
Action: lambda:InvokeFunction
Principal:
Fn::Join: ["",["apigateway.", { Ref: "AWS::URLSuffix"}]]
Authorizer:
DependsOn:
- ApiGatewayRestApi
Type: AWS::ApiGateway::Authorizer
Properties:
Name: ${self:provider.stage}-Authorizer
RestApiId: { "Ref" : "ApiGatewayRestApi" }
Type: TOKEN
IdentitySource: method.request.header.Authorization
AuthorizerResultTtlInSeconds: 300
AuthorizerUri:
Fn::Join:
- ''
-
- 'arn:aws:apigateway:'
- Ref: "AWS::Region"
- ':lambda:path/2015-03-31/functions/'
- Fn::GetAtt: "AuthorizerLambdaFunction.Arn"
- "/invocations"
Outputs:
AuthorizerId:
Value:
Ref: Authorizer
Export:
Name: authorizerId
apiGatewayRestApiId:
Value:
Ref: ApiGatewayRestApi
Export:
Name: restApiId
apiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
Export:
Name: rootResourceId
products serverless
service: products-list
provider:
name: aws
runtime: nodejs12.x
region: ap-south-1
profile: xxx-dev
apiGateway:
restApiId:
Fn::ImportValue: authorizer-stack-dev-restApiId
restApiRootResourceId:
Fn::ImportValue: authorizer-stack-dev-rootResourceId
functions:
get-products:
handler: handler.getProducts
events:
- http:
path: /api/products
method: get
authorizer:
type: CUSTOM
authorizerId:
Fn::ImportValue: authorizer-stack-dev-authorizerId
I am getting the following errors at random
An error occurred: products-list-dev - No export named authorizer-stack-dev-restApiId found.
An error occurred: products-list-dev - No export named authorizer-stack-dev-rootResourceId found.
An error occurred: products-list-dev - No export named authorizer-stack-dev-authorizerId found.
What am I missing here?
serverless -v
Framework Core: 1.74.1
Plugin: 3.6.15
SDK: 2.3.1
Components: 2.31.10
From the shared authorizers I have configured in the past it is not necessary to go to the effort you have undergone. The documentation on the Serverless Framework site has a much simpler setup to achieve a shared authoriser and I will always go with the simplest solution possible: https://www.serverless.com/framework/docs/providers/aws/events/apigateway#share-authorizer

Swagger Codegen for OAS3

I'm trying to use Swagger Codegen for my OAS3 project.
I have cloned swagger-codegen branch 3.0.0. and when I run the generate command I get the following error:
[main] ERROR io.swagger.parser.SwaggerCompatConverter - failed to read resource listing
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')
at [Source: (String)"openapi: 3.0.0
Does Codegen supports openapi 3.0.1 yet? If yes what am I missing ?
UPDATE - Yaml file and codegen command
Petstore.yaml file :
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Codegen command:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
java -jar ./swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i "./definitions/petstoreV3.yaml" -l javascript -o "$SCRIPT_DIR/.swagger_gen_temp"
The error occurs because you are running V2 codegen (from the master branch) instead of V3 codegen (from the 3.0.0 branch). V2 codegen does not support OpenAPI 3.0.
You can download the JAR of V3 codegen from:
http://central.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.11/swagger-codegen-cli-3.0.11.jar
V3 codegen, however, does not currently have a JavaScript client generator.

How to implement Log4j2 custom layout yaml configuration

I am using custom layout for log4j2 framework. How to specify custom layout in log4j2 yaml configuration file ?
The sample I tried is given below. This does not work at the moment saying invalid element 'layout'.
Configutation:
status: warn
packages: uk.co.logging.layout
Properties:
Property:
name: logging.dir
value: ./default_log_dir/
Property:
name: service.name
value: default
Appenders:
Console:
name: CONSOLE
layout: ConnectJsonLayout
policies:
TimeBasedTriggeringPolicy:
interval: 1
modulate: true
SizeBasedTriggeringPolicy:
size: 250MB
RollingFile:
- name: APPLICATION
fileName: ${logging.dir}/${service.name}.log
filePattern: ${logging.dir}/${date:yyyy-MM}/${service.name}-%d{yyyy-MM-dd}-%i.log.gz
layout: ConnectJsonLayout
policies:
TimeBasedTriggeringPolicy:
interval: 1
modulate: true
SizeBasedTriggeringPolicy:
size: 250MB
Loggers:
Root:
level: error
AppenderRef:
- ref: CONSOLE
- ref: APPLICATION
Logger:
- name: uk.co.xxx
additivity: false
level: debug
AppenderRef:
- ref: CONSOLE
- ref: APPLICATION
Kind Regards,
Kiran
Configutation:
status: warn
packages: uk.co.logging.layout
Properties:
Property:
name: logging.dir
value: ./default_log_dir/
Property:
name: service.name
value: default
Appenders:
Console:
name: CONSOLE
ConnectJsonLayout: {}
Loggers:
Root:
level: error
AppenderRef:
- ref: CONSOLE

Resources