Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-route53] Improve error message when domain for hosted zone is undefined #10053

Closed
bahrmichael opened this issue Aug 29, 2020 · 3 comments · Fixed by #21596
Closed

[aws-route53] Improve error message when domain for hosted zone is undefined #10053

bahrmichael opened this issue Aug 29, 2020 · 3 comments · Fixed by #21596
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@bahrmichael
Copy link

#:question: General Issue

I tried to deploy a stack that had the following code:

export class WildcardSubdomainsStack extends cdk.Stack {

  private readonly domain: string;

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    
    const domain = `picture.bahr.dev`;
    
    // this.domain is undefined
    const hostedZone = HostedZone.fromLookup(this, 'HostedZone', { domainName: this.domain });
 }
}

I had an error there, as I should have accessed the local variable, and not the construct variable domain.

It took me however quite long to find this issue, because the error message didn't give me much information.

Cannot read property 'endsWith' of undefined
Subprocess exited with error 1
Error: Subprocess exited with error 1
    at ChildProcess.<anonymous> (/Users/michaelbahr/Documents/dev/wildcard-subdomains/node_modules/aws-cdk/lib/api/cxapp/exec.ts:118:23)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:485:12)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)

Figuring out this problem through the source code is not possible, as the mapping files for exec.ts don't seem to contain any endsWith.

The Question

Could you add some sanity checks that lead to a more descriptive error message?

Environment

  • CDK CLI Version: 1.60.0 (build 8e3f53a)
  • Module Version: 1.60
  • Node.js Version: v13.14.0
  • OS: OSX Mojave
  • Language (Version): "typescript": "~3.7.2"
@bahrmichael bahrmichael added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Aug 29, 2020
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Aug 29, 2020
@SomayaB SomayaB added feature-request A feature should be added or improved. and removed guidance Question that needs advice or information. labels Sep 4, 2020
@shivlaks shivlaks added effort/small Small work item – less than a day of effort p1 labels Oct 15, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 6, 2020
@NGL321 NGL321 assigned njlynch and unassigned shivlaks Jan 25, 2021
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 17, 2022
@bahrmichael
Copy link
Author

Are you planning to update this, or won't it be an issue with CDK v2 anymore?

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 21, 2022
@mergify mergify bot closed this as completed in #21596 Aug 15, 2022
mergify bot pushed a commit that referenced this issue Aug 15, 2022
…` is undefined (#21596)

If TypeScript compiler option `strictPropertyInitialization` is set to `false`, it is possible to pass an undefined value to the `fromLookup` method in `HostedZone`. Currently the error message `Cannot read property 'endsWith' of undefined` will be displayed. This error message does not indicate the root cause, so it is difficult to fix the problem.

This fix introduces an additional check that shows an appropriate error message.

Fixes #10053.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

josephedward pushed a commit to josephedward/aws-cdk that referenced this issue Aug 30, 2022
…` is undefined (aws#21596)

If TypeScript compiler option `strictPropertyInitialization` is set to `false`, it is possible to pass an undefined value to the `fromLookup` method in `HostedZone`. Currently the error message `Cannot read property 'endsWith' of undefined` will be displayed. This error message does not indicate the root cause, so it is difficult to fix the problem.

This fix introduces an additional check that shows an appropriate error message.

Fixes aws#10053.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants