Hidden annotation does not hide methods from help text
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
The javadoc for *@Hidden* mentions that it hides methods and/or interfaces, but the filtering of *@Hidden* for *\--help* only works for interfaces while methods with the annotation are still visible.
For example, in *PipelineOptions* the optionsId getter is set with the *Hidden* annotation, but when *–help* is executed, it appears in the list:
```
org.apache.beam.sdk.options.PipelineOptions:
--jobName=
Default: JobNameFactory
Name of the pipeline execution.It must match the regular expression
'[a-z]([-a-z0-9]{0,38}[a-z0-9])?'.It
defaults to
ApplicationName-UserName-Date-RandomInteger
--optionsId=
Default: AtomicLongFactory
...
--userAgent=
Default: UserAgentFactory
...
```
A proper fix should be skip methods marked with the Hidden class when performing print help [1]. Additionally, a test should be added to *PipelineOptionsReflectorTest* [2] or factory test.
[1] [https://github.com/apache/beam/blob/19bdad654550958f5749ebfcedc3981240127b05/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L581](https://github.com/apache/beam/blob/19bdad654550958f5749ebfcedc3981240127b05/sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java#L581)
[2] [https://github.com/apache/beam/blob/48f9cce76cf87ffe7073c3ad9c34a9f2f6de4b76/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsReflectorTest.java#L120](https://github.com/apache/beam/blob/48f9cce76cf87ffe7073c3ad9c34a9f2f6de4b76/sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsReflectorTest.java#L120)
Imported from Jira [BEAM-4227](https://issues.apache.org/jira/browse/BEAM-4227). Original Jira may contain additional context.
Reported by: pgerv12.
Contributor guide
Research direction
Start in sdks/java/core/src/main/java/org/apache/beam/sdk/options/PipelineOptionsFactory.java around the help-printing logic referenced in the issue. Add or update coverage in sdks/java/core/src/test/java/org/apache/beam/sdk/options/PipelineOptionsReflectorTest.java, or the relevant factory test, and verify that the Hidden-annotated optionsId method is absent from --help output while other options remain visible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100